Georg Heiler
Georg Heiler

Reputation: 17676

using RStudio with self compiled R

How can I get RStudio to recognize my version of R which is installed to

/opt/R/3.4.3/

by compiling it myself (make install) and ln -s /opt/R/${R_VERSION}/bin/R /bin/R. When executing on a shell, R works just fine. Only RStudio does not recognize the different path and is still looking at:

/usr/local/lib64/R/bin/exec/R

exact error message:

Feb  3 14:50:18 devbox systemd: Starting RStudio Server...
Feb  3 14:50:18 devbox systemd: Started RStudio Server.
Feb  3 14:50:18 devbox rserver[22411]: ERROR R did not return any output when queried for directory location information; LOGGED FROM: bool rstudio::core::r_util::<unnamed>::detectRLocationsUsingR(const std::string&, rstudio::core::FilePath*, rstudio::core::FilePath*, rstudio::core::config_utils::Variables*, std::string*) /root/rstudio/src/cpp/core/r_util/REnvironmentPosix.cpp:483
Feb  3 14:50:18 devbox rserver[22411]: ERROR system error 71 (Protocol error) [description=Unable to parse version from R, version-info=, r-error=/usr/local/lib64/R/bin/exec/R: error while loading shared libraries: libmkl_gf_lp64.so: cannot open shared object file: No such file or directory|||]; OCCURRED AT: rstudio::core::Error rstudio::core::r_util::rVersion(const rstudio::core::FilePath&, const rstudio::core::FilePath&, const std::string&, std::string*) /root/rstudio/src/cpp/core/r_util/REnvironmentPosix.cpp:784; LOGGED FROM: bool rstudio::core::r_util::detectREnvironment(const rstudio::core::FilePath&, const rstudio::core::FilePath&, const std::string&, std::string*, std::string*, rstudio::core::r_util::EnvironmentVars*, std::string*) /root/rstudio/src/cpp/core/r_util/REnvironmentPosix.cpp:678

I realized (see answer below) that R only worked as long as I did not loose the current bash environment. Executing:

source /opt/intel/mkl/bin/mklvars.sh intel64

fixes this. However, I cant get RStudio to execute this before starting up. I played around with ExecStartPre=/opt/intel/mkl/bin/mklvars.sh intel64, but it fails to get the environment up correctly

Upvotes: 2

Views: 552

Answers (2)

Georg Heiler
Georg Heiler

Reputation: 17676

I manually need to load

source /opt/intel/mkl/bin/mklvars.sh intel64

into the environment for R to work, as otherwise links are broken and R won't start up which leads to RStudio complaining (with a not 100% helpful error message).

Upvotes: 1

rcs
rcs

Reputation: 68839

On Linux, RStudio Desktop and Open-Source Server use the version of R pointed to by the output of which R. If RStudio is unable to locate R using which R, it will fall back to scanning explicitly for the R script in the /usr/local/bin and /usr/bin directories.

If you want to override which version of R is used then you can set the RSTUDIO_WHICH_R environment variable to the R executable that you want to run against. For example:

export RSTUDIO_WHICH_R=/usr/local/bin/R

See RStudio Support: Using Different Versions of R

Upvotes: 2

Related Questions