Integration with install2.r command in dockerfiles
Closed this issue · 9 comments
Hey folks, first congratulation for this great and much needed project!
I'd like to know if it is possible to use bspm
with install2.r
command inside dockerfiles?
The problem with install.packages()
is that it will not return an error if the installation failed (workarounds exist but there are inconvenient...)
Lastly, I could not install bspm
in Ubuntu 20.04 via sudo apt-get update && sudo apt-get install r-cran-bspm
, it returns E: Unable to locate package r-cran-bspm
. What I'm doing wrong?
Thank you
Hey folks, first congratulation for this great and much needed project!
Much appreciated!
I'd like to know if it is possible to use
bspm
withinstall2.r
command inside dockerfiles?
The problem withinstall.packages()
is that it will not return an error if the installation failed (workarounds exist but there are inconvenient...)
Yes, you can, e.g.:
$ docker run --rm -it rocker/r-bspm:20.04 install2.r Rcpp
(loaded the methods namespace)
Loading required package: utils
Tracing function "install.packages" in package "utils"
Install system packages as root...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Get:1 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease [18.1 kB]
Hit http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit http://ppa.launchpad.net/edd/r-4.0/ubuntu focal InRelease
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Get:4 http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal InRelease [17.5 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:6 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main Sources [1822 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [938 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [29.6 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [210 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1066 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [4301 B]
Get:12 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [658 kB]
Get:13 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 Packages [868 kB]
Get:14 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [675 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [178 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [21.6 kB]
Get:17 http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal/main Sources [9458 B]
Get:18 http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal/main amd64 Packages [8048 B]
Fetched 6846 kB in 0s (0 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
Get:1 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 r-cran-rcpp amd64 1.0.6-1cran1.2004.0 [2039 kB]
Fetched 2039 kB in 0s (0 B/s)
Selecting previously unselected package r-cran-rcpp.
(Reading database ... 20588 files and directories currently installed.)
Preparing to unpack .../r-cran-rcpp_1.0.6-1cran1.2004.0_amd64.deb ...
Unpacking r-cran-rcpp (1.0.6-1cran1.2004.0) ...
Setting up r-cran-rcpp (1.0.6-1cran1.2004.0) ...
Lastly, I could not install
bspm
in Ubuntu 20.04 viasudo apt-get update && sudo apt-get install r-cran-bspm
, it returnsE: Unable to locate package r-cran-bspm
. What I'm doing wrong?
The package can be found in @eddelbuettel's ppa. See r-bspm's dockerfile for reference.
Hi @GitHunter0 (do you have a real name? sometimes it is nice to know who one is dealing with)
In short, you missed one or two key aspects:
- When
bspm
is instrumented, it affects every use ofinstall.packages()
and is hence independent of the caller:install.r
, install2.r, ... work just like everything else that _eventually_ calls
install.packages()`. It really is like magic! - I am making good use of this in the bspm rocker container as illustrated, and have more example (see my blog under the r4 tag
- I am also making very good use of this in CI via the
run.sh
script of myr-ci
project: essentially every single one of my CI runs usesbspm
as my standardci.yaml
"opts into" it (and I may make it a default option)
Hope this helps.
What I'm doing wrong?
I keep forgetting what it is but it will be documented in the bspm
package -- I think it is just one or two global setting to enabling the magic tracing of install.packages()
to dispatch to the matching Python and systemd glue to actually call apt
when we can. The Dockerfile does
# ... stuff omitted ...
&& echo "bspm::enable()" >> /etc/R/Rprofile.site \
&& echo "options(bspm.sudo=TRUE)" >> /etc/R/Rprofile.site \
# ... stuff omitted ...
And strictly speaking there are 'two' PPAs. The one at Lauchpad for Ubuntu, and I made another ad-hoc one for Debian that hangs off Github.
Thank you for your valuable feedback , @Enchufa2 , @eddelbuettel
I managed to successfully use bspm in dockerfiles having r-ubuntu:20.04
as base image.
However, when I try to use it having rstudio:4.0.4
as base image, two issues occurred:
(1) bspm
does not appear in the installed packages list of RStudio
(2) The commands passed to Rprofile.site
are not running in the beginning of R sessions
Here is a minimum working example of dockerfile:
FROM docker.io/rocker/rstudio:4.0.4
RUN apt-get update && apt-get install -y software-properties-common \
&& add-apt-repository --yes "ppa:edd/r-4.0" \
&& apt-get install -y --no-install-recommends r-cran-bspm \
&& echo "bspm::enable()" >> "/etc/R/Rprofile.site" \
&& echo "options(bspm.sudo=TRUE)" >> "/etc/R/Rprofile.site"
RUN install2.r --error --skipinstalled data.table
# Just to test:
RUN echo "x=100 ; print(x); library(data.table)" >> "/etc/R/Rprofile.site"
Hi @GitHunter0 (do you have a real name? sometimes it is nice to know who one is dealing with)
Now I'm just a magician, don't have a name anymore, but at birth I was called Flavio Machado.
AFAIK, rocker/rstudio is tied to rocker/r-ver, which sets a different set of library paths (under /usr/local
) precisely to avoid using system packages.
Understood, thank you @Enchufa2
Ah last question if I may, @Enchufa2
AFAIK, rocker/rstudio is tied to rocker/r-ver, which sets a different set of library paths (under
/usr/local
) precisely to avoid using system packages.
Therefore, install2.r
command won't work with bspm
in that case, right?
So, as an alternative to make that work, one should install bspm
via something like:
RUN R -e "install.packages('bspm', repos='https://packagemanager.rstudio.com/all/__linux__/focal/latest')"
Is that the correct approach?
r-ver
does not use r-cran-* binaries.
So, as an alternative to make that work, one should install
bspm
via something like:
RUN R -e "install.packages('bspm', repos='https://packagemanager.rstudio.com/all/__linux__/focal/latest')"
Is that the correct approach?
Nope, the correct approach is to build a custom dockerfile that doesn't use r-ver
at all. My suggestion is to build on top of r-bspm
. You can add the recipe to install RStudio there.