bioconductor_docker
bioconductor_docker copied to clipboard
Why not use R_LIBS_* variables instead of hard-coded container library?
Related to https://github.com/Bioconductor/bioc_docker/issues/93
In these lines, you prepend a within-container path to R_LIBS.
https://github.com/Bioconductor/bioconductor_docker/blob/211bffff16aa371d272f4d2d772f3be1631f2e51/Dockerfile#L153-L154
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:
- I cannot install a local higher-priority version of something you've stuck into
/usr/local/lib/R/library
within the container. - 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:
- It's the expected way that R has established library locations. So, it's already familiar to R users
- 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?
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?
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.
Hi @nturaga did you ever track down if it's possible to solve this problem?
the same problem
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?
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.