Issue
R volunteers currently maintain Ubuntu package repositories for R ~3.5 and ~4.0. For Bionic Beaver, these are:
- https://cloud.r-project.org/bin/linux/ubuntu/bionic-cran35/
- https://cloud.r-project.org/bin/linux/ubuntu/bionic-cran40/
I am building separate Singularity containers, into which I need very specific versions of R installed; which appear to be provided in these repositories. Specifically, I'm looking to build containers containing R versions 3.6.1, 4.0.3 and 4.1.0; one container per version.
I do this, in the container build script, by first adding the appropriate Apt source, then running the install with a pinned version. I noticed that I could only get it to run if I use the precise version numbers listed in the package repository and also include r-recommended
at the same version. For example, for R 3.6.1:
apt install -y r-base=3.6.1-3bionic r-recommended=3.6.1-3bionic
This correctly installs r-base
and r-recommended
at the given versions. However, when I run the containerised R, R is actually reporting itself to be at the latest version provided by those repositories (3.6.3, 4.1.0 and 4.1.0, respectively). Presumably, given r-base
is correct, this may even suggest them to be in a broken state.
Looking through Apt's output, it's clear that many other r-*
packages are defaulting to the latest versions, rather than the versions I specified. In an attempt to get around this, I tried explicitly setting the versions on all the packages that are defaulting to the latest version. For example, again with R 3.6.1:
apt install -y r-base=3.6.1-3bionic \
r-base-core=3.6.1-3bionic \
r-base-dev=3.6.1-3bionic \
r-base-html=3.6.1-3bionic \
r-doc-html=3.6.1-3bionic \
r-recommended=3.6.1-3bionic
However, this refuses to work, complaining about conflicts with other packages it's trying to install (r-cran-*
packages, IIRC).
I don't know if this is an Apt-thing, an R-thing, or something to do with their repositories. Is there a way I can get these specific versions installed from the official sources, without having to build anything myself? (If not, what's the point of them keeping the older versions in their repositories?)
Solution
Thanks to @Chris' tip-off, the structure of said R packages is important to understand.
r-base
is a metapackage which includes, amongst other things, r-base-core
and r-recommended
. r-recommended
is another metapackage which includes a suite of recommended R packages, which introduce the incompatibility when trying to pin to versions.
For just the R binaries and the documentation, pinned to a specific ${VERSION}
, this will do the trick:
apt install -y --no-install-recommends \
r-base-core=${VERSION} \
r-base-html=${VERSION} \
r-doc-html=${VERSION}
If you want to build packages, you'd also want r-base-dev=${VERSION}
in there.
Answered By - Xophmeister