25.7 Troubleshooting Docker

25.7.1 “Package not available” while building images

PROBLEM: Packages fail to install while building pecan/depends and/or pecan/base with an error like the following:

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository <URL>:
 cannot open URL '<URL>'
Warning message:
package ‘<PACKAGE>’ is not available (for R version 3.5.1)

CAUSE: This can sometimes happen if there are problems with the RStudio Package manager, which is the default repository for the rocker/tidyverse containers. See GitHub issues rocker-org/rocker-versioned#102 and #58.

WORKAROUND: Add the following line to the depends and/or base Dockerfiles before (i.e. above) any commands that install R packages (e.g. Rscript -e "install.packages(...)"):

RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.org'))" >> /usr/local/lib/R/etc/Rprofile.site

This will set the default repository to the more reliable (albeit, more up-to-date; beware of breaking package changes!) RStudio CRAN mirror. Then, build the image as usual.