skip to Main Content

Summary

I am currently building a docker image with RStudio that is based on a previous version of R. When I installed R libraries in that image and tried to access those libraries with another, prebuilt docker image I received the following message:

library("dplyr")

Warning message:
package ´dplyr´ was built under R version 4.1.2

For some reason the R version I get and the R version I install are not the same. Is there some way to inspect the packages on https://cran.r-project.org/bin/linux/ubuntu/focal-cran40/? What is the reason for the discrepancy between my requested R version of 4.0.4 and the installed version of 4.1.2?

What I have tried

In my dockerfile I explicitly define my target version of 4.0.4.
RUN apt-get install -y r-base=4.0.4-1.2004.0 r-recommended=4.0.4-1.2004.0

When I verify my R Version it does show 4.1.2:
Rscript -e 'R.Version()$version.string'

[1] "R version 4.1.2 (2021-11-01)"

When I verify my R installation it shows that 4.0.4 is installed:
apt policy r-base

 r-base:  
  Installed: 4.0.4-1.2004.0  
  Candidate: 4.1.2-1.2004.0  
  Version table:  
     4.1.2-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
     4.1.1-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
     4.1.0-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
     4.0.5-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
 *** 4.0.4-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
        100 /var/lib/dpkg/status  
     4.0.3-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
     4.0.2-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
     4.0.1-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
     4.0.0-1.2004.0 500  
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages  
     3.6.3-2 500  
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages  

Steps to reproduce:

I start with a clean Ubuntu 20.04 image.
docker run -it --entrypoint bash ubuntu:focal

I make sure I am current and then add some packages.

apt-get update && apt-get upgrade -y
apt-get install -y --no-install-recommends software-properties-common dirmngr gdebi-core curl

tzdata wants some info during the installation (this can be anything I suspect):

1
1

Add the signing key for the r-project repos and add the repo. $(lsb_release -cs) resolves to "focal".

curl https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc > /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc  
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

Check the available r-base package versions:
apt policy r-base

r-base:
  Installed: (none)
  Candidate: 4.1.3-1.2004.0
  Version table:
     4.1.3-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.5-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.4-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.3-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     3.6.3-2 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages

Install R:
apt-get install -y r-base=4.0.4-1.2004.0 r-recommended=4.0.4-1.2004.0

Check the installed Version:
Rscript -e 'R.Version()$version.string'

[1] "R version 4.1.3 (2022-03-10)"

What am I missing? Is it possible that there might be some issue with the r-rpoject repo?

Thanks for your inputs!

2

Answers


  1. Chosen as BEST ANSWER

    As suggested by Dirk Eddelbuettel the issue lies with how I tried to install the packages.

    r-base and r-recommended are meta-packages that contain further packages. Meta packages can be requested by version but do not propagate the requested version down to their child packages.
    This means if you want to install a specific version of R the binary is included in r-base-core. The same goes for r-recommended and the recommended R base packages which can be installed via apt into /usr/lib/R/library.

    To install the specific version of R that is needed the following can be written to the Dockerfile:

    ARG R_INSTALL_VERSION="4.0.4-1.2004.0"
    RUN apt-get install -y  
      r-base-core=${R_INSTALL_VERSION} 
      r-base-html=${R_INSTALL_VERSION} 
      r-doc-html=${R_INSTALL_VERSION} 
      r-base-dev=${R_INSTALL_VERSION} 
    

    Note that r-recommended was excluded here since 11 out of 15 base packages had dependency issues as described above.
    If those packages are needed one can list the available versions of a package via apt policy <package-name> and pick a version that is compatible with the requested R version.
    This package version does not correspond to the R Version:

    ARG R_INSTALL_VERSION="4.0.4-1.2004.0"
    RUN apt-get install -y  
      r-base-core=${R_INSTALL_VERSION} 
      r-base-html=${R_INSTALL_VERSION} 
      r-doc-html=${R_INSTALL_VERSION} 
      r-base-dev=${R_INSTALL_VERSION} 
      r-cran-cluster=2.1.1-1.2004.0 
      ...
    

  2. As per my comment above, this seems confused.

    You open up with "binary from the PPA are built under a more current version": yes, and that is a feature. If you do not want a current dplyr (via a current r-cran-dplyr) then do not add the PPA by Michael (which you do correctly by following the steps at the README.

    The disconnect, if there is one, is that you seem to think that you point to that PPA and somehow get versions matching an arbitrarily picked R version, here your 4.0.4. You cannot, and we never say you can.

    What we provide via the CRAN mirror of the other Rutter PPA are

    • current versions of R for the various operating systems, i.e. Michael tweeted just yesterday that 4.0.3 is now available off my Debian binaries
    • about 5000 additional binaries off CRAN for the LTS release but also generally built with most current R version—which is why the dplyr binary signalled it was built recently under 4.0.4

    So in short this is not a time machine mechanism.

    (For that you can look into the RSPM builds for which I have a container rocker/r-rspm:20.04 to use RSPM, you could try the date-indexing support they offer. I don’t use enable that by default.)

    If I misunderstood anything, please add a comment and maybe clarify above. The r-sig-debian list is also available for more follow-up.

    Edit: Per the discussion in the comments, we now know better. OP constrained just one package from the set and expected that apt would magically expand. That is not how it happens. Based on some other Dockerfile I wrote, I recommend something along the lines of

        && apt-get install -t unstable -y --no-install-recommends 
                # ... some omitted ...
                r-base=${R_BASE_VERSION}-* 
                r-base-dev=${R_BASE_VERSION}-* 
                r-recommended=${R_BASE_VERSION}-* 
                # ... more lines omitted ...
    

    which is how I impose versions when I build the r-base container. The versioned r-base-dev will pull in the versioned r-base-core container, you could also list it explicitly.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search