On this topic, I've also been trying to install multiple version of R for use with our company RStudio Server Pro install (1.2.1335). Running on Ubuntu 16.04, we use the base install of R (which Ubuntu auto updates to latest version, currently 3.6.0) so we need to compile specific version of R from source in /opt/R/version. I've set up site-library locations in /usr/local/lib/R-MAJOR-MINOR/site-library to manage packages which can be shared by matching installs of R in /opt/R/MAJOR-MINOR-SUBMINOR. I followed article 215488098 to build from source and tried building against system blas/lapack libs.
Now, to make the built versions of R work correctly, RStudio needs to set up library paths correctly - there are docs here for this running on a single install of R here: https://docs.rstudio.com/ide/server-pro/r-sessions.html#r-executable-and-libraries. There are also enhancements to RStudio Server Pro to run individual configuration scripts for each version of R here: https://docs.rstudio.com/ide/server-pro/r-versions.html#using-multiple-versions-of-r-concurrently (running modules or scripts to configure each of these), but no examples of a configuration.
My question is, how do I ensure the correct dynamic library path is configured to run more than just the default pre-installed R version. What is the interaction of the /etc/rstudio/rserver.conf variables with the scripts that can be configured in /etc/rstudio/r-versions ? Do these script come before/after/instead of rserver.conf variable processing ? How does the module work instead of a script, what's recommended ?
I am currently getting errors if I switch to any built-from-source R versions - basic print breaks indicating that R cannot even find its standard library (to avoid complications I built R from source using the most basic config: ./configure --prefix=/opt/R/VERSION --enable-R-shlib) - clearly LD_LIBRARY_PATH is not getting set correctly. I am about to do some more digging turning on diagnostics etc, but an extended example to make all this work would be appreciated to promote best practices!
More info on this:
I installed a few test versions of R in /opt/R/VERSION as indicated above and set up /etc/rstudio/r-versions like so:
Path: /opt/R/3.5.2
Label: R 3.5.2
Path: /opt/R/3.5.3
Label: R 3.5.3
Path: /opt/R/3.6.0
Label: R 3.6.0
Path: /usr/lib/R
Label: System R
/etc/rstudio/rserver.conf looks like this:
# Server Configuration File
www-port=8899
#rsession-which-r=/opt/R/3.5.2/bin/R
server-license-type=remote
r-versions-scan=1
admin-enabled=1
admin-group=rstudio-admins
rsession-diagnostics-enabled=1
Switching to one of the built versions of R in the Studio context menu fails to switch to the required version of R and gives the following errors (in console):
Error in .Internal(print.function(x, useSource, ...)) :
there is no .Internal function 'print.function'
Looking into the session log starting with the switch to R 3.5.3, this is the output (libR.so seems to be found - I'm removing proxy settings which are irrelevant here)
[Wed May 22 12:17:43 AEST 2019] ---- launching rsession process ----
[Wed May 22 12:17:43 AEST 2019] ---- final env ----
[Wed May 22 12:17:43 AEST 2019] RS_SESSION_SERVER_RPC_SECRET=bc7304ed5f324a58a962f179620d4952
R_INCLUDE_DIR=/opt/R/3.5.3/lib/R/include
RSTUDIO_DEFAULT_R_VERSION=3.6.0
RSTUDIO_REQUIRED_USER_GROUP=
RSTUDIO_MULTI_SESSION=1
RSTUDIO_VERSION=1.2.1335-1
RSTUDIO_LIMIT_RPC_CLIENT_UID=999
RSTUDIO_R_MODULE=
RSESSION_PROFILE_OPTIONS=
RS_R_VERSIONS_PATH=/var/lib/rstudio-server/r-versions
LD_LIBRARY_PATH=/opt/R/3.5.3/lib/R/lib::/lib:/usr/local/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server
RS_MONITOR_SHARED_SECRET=8bdeb08d-0c8c-4de8-abe8-a661b1a9bbee
RSESSION_DIAGNOSTICS_FILE=/tmp/rsession-diagnostics-w49700-20a96e6f.log
RSTUDIO_USER_HOME_PAGE=1
RSTUDIO_R_PRELAUNCH_SCRIPT=
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
PWD=/
R_SHARE_DIR=/opt/R/3.5.3/lib/R/share
LANG=en_US.UTF-8
RSTUDIO_MINIMUM_USER_ID=1000
RSTUDIO_R_VERSION_LABEL=R 3.5.3
RSESSION_DIAGNOSTICS_ENABLED=1
SHLVL=1
R_HOME=/opt/R/3.5.3/lib/R
R_DOC_DIR=/opt/R/3.5.3/lib/R/doc
RSTUDIO_DEFAULT_R_VERSION_HOME=/usr/lib/R
_=/usr/bin/printenv
[Wed May 22 12:17:43 AEST 2019] ---- ldd output ----
[Wed May 22 12:17:43 AEST 2019] linux-vdso.so.1 => (0x00007ffdce5f3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd6458c5000)
libR.so => /opt/R/3.5.3/lib/R/lib/libR.so (0x00007fd64524a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd64502d000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fd644e2a000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fd644c25000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd644a1d000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd644803000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fd64459a000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fd644155000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd643dd3000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd643aca000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd6438b4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd6434ea000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd646c08000)
libRblas.so => /opt/R/3.5.3/lib/R/lib/libRblas.so (0x00007fd6432bd000)
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fd643077000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fd642e07000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fd642be5000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007fd6429d5000)
libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007fd642641000)
libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007fd6421df000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007fd641fbd000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fd641d94000)
libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007fd6402dd000)
RStudio has failed to switch R versions, showing R version as R 3.6.0 (using R.version and console manifest) still with errors at every command. I tried this on an existing project and a new project choosing R 3.5.3 configuring the new project. Running this R version from console works fine (given the R script which configures necessary env vars with paths before invoking the binary - RStudio does not use this script for obvious reasons so need to understand which order/which config files should be set up to achieve the same, R version install specific, effect).
Digging a bit further, it appears LD_LIBRARY_PATH is NOT set appropriately for this R version - in RStudio (/opt/R/3.5.3/lib/R/lib is appended way down the chain as opposed to being picked up earlier)
/usr/lib64/openmpi/lib/:/usr/local/cuda/lib64:/usr/local/lib:/usr/lib:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/mpi/lib:/lib/:/opt/R/3.5.3/lib/R/lib::/lib:/usr/local/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server
compared to console invocation of R 3.5.3:
/opt/R/3.5.3/lib/R/lib:/usr/local/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server:/usr/lib64/openmpi/lib/:/usr/local/cuda/lib64:/usr/local/lib:/usr/lib:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/mpi/lib:/lib/:
where you can see /opt/R/3.5.3/lib/R/lib being prepended to the path. However according to the rsession log, R should be happy as it's found the right libR.so
Thanks in advance!
Bernard
P.S. I had to mangle the references in this post as I'm a new user and not allowed to put more than 2 links ?