rstudio / packrat

Packrat is a dependency management system for R
http://rstudio.github.io/packrat/
399 stars 89 forks source link

test-load installed binary packages #712

Closed aronatkins closed 1 year ago

aronatkins commented 1 year ago

R package binaries are not loaded during installation; missing or incompatible system libraries are not detected until the package is loaded at runtime.

We can see this problem with the rjags R package, which depends upon the jags system library.

Given this Dockerfile.pkg-config, a binary of rjags installs successfully, but then fails to load.

FROM rstudio/r-base:4.3-jammy

RUN apt-get update && apt-get -y install pkg-config

ARG REPOSITORY=https://packagemanager.rstudio.com/cran/__linux__/jammy/latest
RUN R -s -e "install.packages('rjags', repos=c(CRAN='${REPOSITORY}'))" && R -s -e "cat('POST-INSTALL:\n');library(rjags)"

Building:

docker build --progress=plain \
    --build-arg REPOSITORY=https://packagemanager.rstudio.com/cran/__linux__/jammy/latest \
    -f Dockerfile.pkg-config .

The output includes:

....
#6 2.816 * installing *binary* package ‘rjags’ ...
#6 2.822 * DONE (rjags)
#6 2.836
#6 2.836 The downloaded source packages are in
#6 2.836    ‘/tmp/RtmpOQfoTU/downloaded_packages’
#6 2.836 Updating HTML index of packages in '.Library'
#6 2.838 Making 'packages.html' ... done
#6 3.019 POST-INSTALL:
#6 3.026 Loading required package: coda
#6 3.064 Error: package or namespace load failed for ‘rjags’:
#6 3.064  .onLoad failed in loadNamespace() for 'rjags', details:
#6 3.064   call: dyn.load(file, DLLpath = DLLpath, ...)
#6 3.064   error: unable to load shared object '/opt/R/4.3.0/lib/R/library/rjags/libs/rjags.so':
#6 3.064   libjags.so.4: cannot open shared object file: No such file or directory
#6 3.064 Execution halted

This shows that library-load issues are not detected during installation when using binary packages.