Setting same R library order in RStudio Server and command-line R

Hi,

I would like to have the same library path order on the command-line R and RStudio Server (open source). Is there a way to do this system-wide for all users without having to set .libPaths() at runtime?

Command-line R:

> .libPaths()
[1] "/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Compiler/gcc9/r-bundle-bioconductor/3.14"
[2] "/home/nicolas.dejay/R/x86_64-pc-linux-gnu-library/4.1"
[3] "/cvmfs/[soft.computecanada.ca/easybuild/software/2020/avx512/Core/r/4.1.2/lib64/R/library](http://soft.computecanada.ca/easybuild/software/2020/avx512/Core/r/4.1.2/lib64/R/library)"
Sys.getenv()[grep("R_LIBS", names(Sys.getenv()))]
R_LIBS /cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Compiler/gcc9/r-bundle-bioconductor/3.14
R_LIBS_SITE
R_LIBS_USER ~/R/x86_64-pc-linux-gnu-library/4.1

RStudio Server (and command-line R when ~/R is empty)

> .libPaths()
[1] "/home/kleinman/nicolas.dejay/R/x86_64-pc-linux-gnu-library/4.1"
[2] "/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Compiler/gcc9/r-bundle-bioconductor/3.14"
[3] "/cvmfs/[soft.computecanada.ca/easybuild/software/2020/avx512/Core/r/4.1.2/lib64/R/library](http://soft.computecanada.ca/easybuild/software/2020/avx512/Core/r/4.1.2/lib64/R/library)"
> Sys.getenv()[grep("R_LIBS", names(Sys.getenv()))]
R_LIBS /cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Compiler/gcc9/r-bundle-bioconductor/3.14
R_LIBS_SITE
R_LIBS_USER ~/R/x86_64-pc-linux-gnu-library/4.1

Both RStudio Server and command-line R are using the same version of R and with the following environment variable set:

R_LIBS=/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Compiler/gcc9/r-bundle-bioconductor/3.14

Thank you!

Hi @ndejay,

You could use the .Rprofile.site to set options for all users at startup. This article might be helpful: https://support.posit.co/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf

Hi Alex,

Thanks for your reply, this is really helpful. I am using an R installation on a read-only CernVM-FS mount so I am unable to set up a Rprofile.site under $R_HOME/etc/. Do you know if there is an alternative way to accomplish the same thing?

Best,
Nic

If you can set an env var, then set R_PROFILE to point to your profile elsewhere.

From the ?Startup docs in R:

Then R searches for the site-wide startup profile file of R code
unless the command line option ‘--no-site-file’ was given.  The
path of this file is taken from the value of the ‘R_PROFILE’
environment variable (after tilde expansion).  If this variable is
unset, the default is ‘R_HOME/etc/Rprofile.site’, which is used if
it exists (which it does not in a ‘factory-fresh’ installation).

Hi @Gabor and @alexkgold,

Thanks, that works!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.