Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R package modules have priority over user-installed packages #2200

Closed
zao opened this issue Oct 16, 2020 · 4 comments · Fixed by #2326
Closed

R package modules have priority over user-installed packages #2200

zao opened this issue Oct 16, 2020 · 4 comments · Fixed by #2326

Comments

@zao
Copy link
Contributor

zao commented Oct 16, 2020

R has multiple variables that control the library path, R_LIBS, R_LIBS_USER and R_LIBS_SITE.

The path can be inspected with .libPaths() and is made up of in order of the entries in R_LIBS, R_LIBS_USER and R_LIBS_SITE and last the R installation itself.

Our R package modules currently prepend their path to R_LIBS similar to how PYTHONPATH is handled, but this means that the user's directory (typically specified in ~/.Renviron or the default) is not at the front of the library path.

This means that users cannot override system-installed packages and more importantly, install.packages only ever considers the first entry in the library path unless you explicitly specify a lib= to install to. Some installation functions like install_github doesn't even have that customization point.

I suggest that we alter our R packages to prepend to R_LIBS_SITE instead, it seems to yield the preferred order for an end-user.

Our R installations do not have a bundled site-library directory so the environment variable is currently unused.

Upstream documentation on how the paths are constructed: https://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html

@zao
Copy link
Contributor Author

zao commented Oct 16, 2020

Current state:

b-an02 [~]$ R --quiet --no-save --no-restore -e '.libPaths()'
> .libPaths()
[1] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/R-bundle-Bioconductor/3.11-R-4.0.0"
[2] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/ncdf4/1.17-R-4.0.0"                
[3] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/rgdal/1.5-16-R-4.0.0"              
[4] "/afs/hpc2n.umu.se/home/l/lars/Public/R-packages-4.0.0"                                                                
[5] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/R/4.0.0/lib/R/library"             

Swapping the variables to use R_LIBS_SITE instead:

b-an02 [~]$ env R_LIBS_SITE=$R_LIBS R_LIBS= R --quiet --no-save --no-restore -e '.libPaths()'
> .libPaths()
[1] "/afs/hpc2n.umu.se/home/l/lars/Public/R-packages-4.0.0"                                                                
[2] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/R-bundle-Bioconductor/3.11-R-4.0.0"
[3] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/ncdf4/1.17-R-4.0.0"                
[4] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/rgdal/1.5-16-R-4.0.0"              
[5] "/cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu1604_bdw/software/MPI/GCC/9.3.0/OpenMPI/4.0.3/R/4.0.0/lib/R/library"             

@ocaisa
Copy link
Member

ocaisa commented Nov 4, 2020

Has the behaviour always been like this? We could maintain backwards compatibility by putting in a version check on which envvar to use (but I wonder if that is overkill).

@boegel I can't see a reason why we wouldn't do this.

@akesandgren
Copy link
Contributor

This is clearly something that should be fixed. Does anyone have any objections to changing this?

@akesandgren
Copy link
Contributor

And at least R/3.5.1 and forward has this behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants