I am trying to run R (development) version 4.0 that I compiled from source on a mac as the engine in RStudio. According to the documentation Rstudio for Mac scans for the R executable in the following sequence:
/usr/bin/R
/usr/local/bin/R
/opt/local/bin/R
- whatever version of R is located at
/Library/Frameworks/R.framework/
and this can be overridden by setting the environment variable RSTUDIO_WHICH_R
.
Well, I have a working install at location 2 (ie, can run it from Terminal no problem) and have also tried exporting RSTUDIO_WHICH_R=/usr/local/bin/R
, then opening RStudio with open -an RStudio
in a Terminal. I can verify in Rstudio that the environment variable was set with Sys.getenv
and points to a file:
> file.exists(Sys.getenv('RSTUDIO_WHICH_R'))
[1] TRUE
But I can't for the life of me get RStudio to run anything but the version linked in /Library/Frameworks/R.framework/
. So I suspect that this documentation is no longer accurate for MacOS. Has anyone actually observed the documentation to be accurate?
This is with Rstudio 1.2.5033, R 3.6.1 installed in Frameworks and r77542 installed under /usr/local/bin on a Mac. Running Mojave 10.14.6.
Update
After reading the rstudio source and trying to understand how RSTUDIO_WHICH_R is used, I saw that there was some logging occurring. In ~/.rstudio-desktop/log/rdesktop.log
I see the following:
18 Dec 2019 05:50:30 [rdesktop] ERROR Unable to find libR.dylib in expected locationswithin R Home directory /usr/local/lib/R-4.0.0-devel; LOGGED FROM: bool rstudio::core::r_util::(anonymous namespace)::getLibPathFromRHome(const rstudio::core::FilePath &, std::string *, std::string *) /Users/vagrant/workspace/IDE/macos-v1.2/src/cpp/core/r_util/REnvironmentPosix.cpp:140
So it seems I need to set --enable-R-shlib
when I compile R...stay tuned.