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

Why not use R_LIBS_* variables instead of hard-coded container library? #10

Open
nsheff opened this issue Mar 24, 2020 · 6 comments
Open

Comments

@nsheff
Copy link

nsheff commented Mar 24, 2020

Related to Bioconductor/bioc_docker#93

In these lines, you prepend a within-container path to R_LIBS.

RUN echo "R_LIBS=/usr/local/lib/R/host-site-library:\${R_LIBS}" > /usr/local/lib/R/etc/Renviron.site \
&& echo "options(defaultPackages=c(getOption('defaultPackages'),'BiocManager'))" >> /usr/local/lib/R/etc/Rprofile.site

I believe this is what is precluding me from using the R_LIBS_USER or R_LIBS_SITE variables, because you are forcing the local container lib folder to have a higher priority. This makes these containers unusable for a use case where I want to use the container mount a local library using the traditional method.

For example, I'm running this:

docker run --rm --init -it \
   --user=$(id -u):$(id -g) \
  --network="host" \
  --env "DISPLAY" \
  --env "R_LIBS_USER" \
  --volume "$HOME:$HOME" \
  --volume="/etc/group:/etc/group:ro" \
  --volume="/etc/passwd:/etc/passwd:ro" \
  --volume="/etc/shadow:/etc/shadow:ro"  \
  --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
  --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
  --workdir="`pwd`" \
  bioconductor/bioconductor_docker:RELEASE_3_10 R

and I see:

R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
Bioconductor version 3.10 (BiocManager 1.30.10), ?BiocManager::install for help
> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/local/lib/R/library"     
[3] "/home/nsheff/R/3.6"

The path I passed along via R_LIBS_USER is showing up as the lowest priority library. This causes some problems:

  1. I cannot install a local higher-priority version of something you've stuck into /usr/local/lib/R/library within the container.
  2. When I install a package, sometimes it fails because the highest priority libraries are not writable. BiocManger::install prompts, and installs into /home only if I override:
BiocManager::install("GenomicRanges")
Bioconductor version 3.10 (BiocManager 1.30.10), R 3.6.2 (2019-12-12)
Installing package(s) 'GenomicRanges'
Warning in install.packages(...) :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) yes

, but devtools does not:

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Error: Failed to install 'GenomicDistributions' from GitHub:
  (converted from warning) 'lib = "/usr/local/lib/R/site-library"' is not writable

Workaround

In a nutshell, whatI want to do this:

docker run -it -e R_LIBS_USER=/<path> <image> R

The container setup requires instead, this:

docker run -it --volume=/home/nsheff/.local/lib/R/3.6:/usr/local/lib/R/host-site-library \=/<path> <image> R

The problem with this is that I cannot use a variable (like %v) that will make this persist across different versions of R. This increases the manual overhead required when changing R versions. Furthermore, this means learning a new way to set libraries, where the old way would have worked fine (and in fact, even better). I think the environment variable way is superior because:

  1. It's the expected way that R has established library locations. So, it's already familiar to R users
  2. It is more flexible as you can put system-dependent information in there.

I see no advantages to the forced host mount method. Perhaps I have missed something and there is some limitation preventing my proposal?

@nsheff nsheff changed the title Host site mount point Why not use R_LIBS_* variables instead of hard-coded container library? Mar 24, 2020
@nturaga
Copy link
Collaborator

nturaga commented Apr 13, 2020

Hi @nsheff,

After trying to track down the issue I believe it's being caused upstream of the bioconductor_docker image, specifically in the rocker/r-ver image

https://github.com/rocker-org/rocker-versioned/blob/master/r-ver/latest.Dockerfile#L114

The line which you mentioned above doesn't seem to be causing the issue i'm seeing.

I'll look into this further to try to understand the issue, but it is looking like this might be a rocker problem?

@fedeago
Copy link

fedeago commented Sep 3, 2020

Hi,

I think I have the same problem. When I try to install a package using BiocManager it fails with the following error:

Installation path not writeable, unable to update packages: mgcv

the result of .libPaths() in my case is:

"/usr/local/lib/R/site-library" "/usr/local/lib/R/library"

do someone know how could I solve this problem?

I tried to uninstall mgcv but but it tells me:

Updating HTML index of packages in '.Library'
Warning in remove.packages :
  cannot create file '/usr/local/lib/R/doc/html/packages.html', reason 'Permission denied'
Warning in remove.packages :
  cannot update HTML package index

and if I try to install the new version it do it but in creates a copy of the package and it dosen't change the installation issue.

@nsheff
Copy link
Author

nsheff commented Sep 11, 2020

Hi @nturaga did you ever track down if it's possible to solve this problem?

@Yunuuuu
Copy link

Yunuuuu commented Mar 15, 2021

the same problem

@nturaga
Copy link
Collaborator

nturaga commented Mar 16, 2021

One way to solve this is to just own those two library locations. I'm not sure if it's a problem with prevents usage?

@Yunuuuu
Copy link

Yunuuuu commented Mar 17, 2021

It maybe due to the upstream dependence rocker/rstudio, I have tried to make image begin with Docker Official Images r-base, but I'm not familiar with Dockerfile, I couldn't make a successful image. Finally, I have choosed to modify bioconductor_docker's Dockerfile by including the installation of dependencies library and add a line of code RUN chmod -R a+w /usr/local/lib/R/site-library/ /usr/local/lib/R/library/ in the end of the Dockerfile, and run this modified image with -v path/to/R_LIBS_USER:/usr/local/lib/R/site-library. Now it can work anyway.

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

No branches or pull requests

4 participants