1

In my Dockerfile I have the following lines:

FROM rocker/verse:latest

RUN R -e "install.packages(c('R.utils'), repos = 'https://cran-archive.r-project.org')"

When I run docker build . I got:

> install.packages(c('R.utils'), repos = 'https://cran-archive.r-project.org')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://cran-archive.r-project.org/src/contrib:
  cannot open URL 'https://cran-archive.r-project.org/src/contrib/PACKAGES'
Warning message:
package ‘R.utils’ is not available (for R version 4.0.2)

I'm new to Docker, not too sure what I'm doing wrong. I put https://cran-archive.r-project.org/src/contrib/PACKAGES in browser and it couldn't load, should I try a different repo URL?

Thanks!

Heuristic
  • 5,087
  • 9
  • 54
  • 94

2 Answers2

0

yes, you have to mention the full path to the repo. https://cran.r-project.org/src/contrib/R.utils_2.9.2.tar.gz use this repo link to get R.util.

You can also run the command sudo apt-get install -y r-cran-r.utils to install R.utils

Dharman
  • 30,962
  • 25
  • 85
  • 135
Sahil Yadav
  • 88
  • 1
  • 9
  • https://stackoverflow.com/questions/25721884/how-should-i-deal-with-package-xxx-is-not-available-for-r-version-x-y-z-wa – Sahil Yadav Aug 21 '20 at 03:21
0

Try any of the advertised mirrors, and they should have the most recent release of R.utils for your version of R-4.0.2.

That CRAN mirror is specifically for old versions of R. Since your version of R (4.0.2) is not old, it is not found there. That cran-archive is intended for R versions without support for those packages (ergo the "archive" label, I suspect).

From the R FAQ 2.10:

Since March 2016, “old” material is made available from a central CRAN archive server (https://CRAN-archive.R-project.org/).

Or perhaps from the R for Mac OS X page:

Package binaries for R versions older than 3.2.0 are only available from the CRAN archive so users of such versions should adjust the CRAN mirror setting (https://cran-archive.r-project.org) accordingly.

Both of these suggest that repos = 'https://cran-archive.r-project.org' should be used for old versions of R, but your error reports R-4.0.2 (not old)

r2evans
  • 141,215
  • 6
  • 77
  • 149