rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
1.02k stars 155 forks source link

Running Renv in Docker #1958

Open josh-gree opened 4 months ago

josh-gree commented 4 months ago

I have the following Dockerfile;

FROM r-base:4.4.1

ARG GITHUB_PAT
ENV GITHUB_PAT=$GITHUB_PAT

RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv')"

WORKDIR /project
COPY renv.lock renv.lock

ENV RENV_PATHS_LIBRARY renv/library

RUN GITHUB_PAT=$GITHUB_PAT R -e "options(renv.config.pak.enabled = TRUE); renv::restore()"

It builds successfully - the logs look very much like its picking up, and installing, everything in the lock - when I then run the container and try to use the libraries installed it appears nothing is installed;

> renv::status()
The following package(s) are in an inconsistent state:

 package          installed recorded used
 abind            n         y        n   
 askpass          n         y        n   
 base64enc        n         y        n   
 beeswarm         n         y        n   
 BH               n         y        n   
 BiocGenerics     n         y        n   
 bitops           n         y        n   
 boot             y         y        n   
 bslib            n         y        n   
 cachem           n         y        n   
 caTools          n         y        n   
 circlize         n         y        n   
 class            y         y        n   
 cli              n         y        n   
 clue             n         y        n   
 cluster          y         y        n   
 codetools        y         y        n   
 colorspace       n         y        n   
 commonmark       n         y        n   
 ComplexHeatmap   n         y        n   
 cowplot          n         y        n   
 cpp11            n         y        n   
 crayon           n         y        n   
 crosstalk        n         y        n   
 curl             n         y        n   
 data.table       n         y        n   
 deldir           n         y        n   
 digest           n         y        n   
 discovery        n         y        n   
 doParallel       n         y        n   
 dotCall64        n         y        n   
 dplyr            n         y        n   
 dqrng            n         y        n   
 evaluate         n         y        n   
 fansi            n         y        n   
 farver           n         y        n   
 fastDummies      n         y        n   
 fastmap          n         y        n   
 fitdistrplus     n         y        n   
 FNN              n         y        n   
 fontawesome      n         y        n   
 foreach          n         y        n   
 foreign          y         y        n   
 fs               n         y        n   
 future           n         y        n   
 future.apply     n         y        n   
 generics         n         y        n   
 GetoptLong       n         y        n   
 ggbeeswarm       n         y        n   
 ggplot2          n         y        n   
 ggrepel          n         y        n   
 ggridges         n         y        n   
 GlobalOptions    n         y        n   
 globals          n         y        n   
 glue             n         y        n   
 goftest          n         y        n   
 gplots           n         y        n   
 gridExtra        n         y        n   
 gtable           n         y        n   
 gtools           n         y        n   
 here             n         y        n   
 highr            n         y        n   
 htmltools        n         y        n   
 htmlwidgets      n         y        n   
 httpuv           n         y        n   
 httr             n         y        n   
 ica              n         y        n   
 igraph           n         y        n   
 IRanges          n         y        n   
 irlba            n         y        n   
 isoband          n         y        n   
 iterators        n         y        n   
 jquerylib        n         y        n   
 jsonlite         n         y        n   
 KernSmooth       y         y        n   
 knitr            n         y        n   
 labeling         n         y        n   
 later            n         y        n   
 lattice          y         y        n   
 lazyeval         n         y        n   
 leiden           n         y        n   
 lifecycle        n         y        n   
 listenv          n         y        n   
 lmtest           n         y        n   
 magrittr         n         y        n   
 MASS             y         y        n   
 Matrix           y         y        n   
 matrixStats      n         y        n   
 memoise          n         y        n   
 mgcv             y         y        n   
 mime             n         y        n   
 miniUI           n         y        n   
 munsell          n         y        n   
 nlme             y         y        n   
 nnet             y         y        n   
 openssl          n         y        n   
 pak              n         y        n   
 parallelly       n         y        n   
 patchwork        n         y        n   
 pbapply          n         y        n   
 pillar           n         y        n   
 pkgconfig        n         y        n   
 plotly           n         y        n   
 plyr             n         y        n   
 png              n         y        n   
 polyclip         n         y        n   
 progressr        n         y        n   
 promises         n         y        n   
 purrr            n         y        n   
 R6               n         y        n   
 RANN             n         y        n   
 rappdirs         n         y        n   
 RColorBrewer     n         y        n   
 Rcpp             n         y        n   
 RcppAnnoy        n         y        n   
 RcppArmadillo    n         y        n   
 RcppEigen        n         y        n   
 RcppHNSW         n         y        n   
 RcppProgress     n         y        n   
 RcppTOML         n         y        n   
 renv             y         n        y   
 reshape2         n         y        n   
 reticulate       n         y        n   
 rjson            n         y        n   
 rlang            n         y        n   
 rmarkdown        n         y        n   
 ROCR             n         y        n   
 rpart            y         y        n   
 rprojroot        n         y        n   
 RSpectra         n         y        n   
 Rtsne            n         y        n   
 S4Vectors        n         y        n   
 sass             n         y        n   
 scales           n         y        n   
 scattermore      n         y        n   
 sctransform      n         y        n   
 Seurat           n         y        n   
 SeuratObject     n         y        n   
 shape            n         y        n   
 shiny            n         y        n   
 sitmo            n         y        n   
 sourcetools      n         y        n   
 sp               n         y        n   
 spam             n         y        n   
 spatial          y         y        n   
 spatstat.data    n         y        n   
 spatstat.explore n         y        n   
 spatstat.geom    n         y        n   
 spatstat.random  n         y        n   
 spatstat.sparse  n         y        n   
 spatstat.univar  n         y        n   
 spatstat.utils   n         y        n   
 stringi          n         y        n   
 stringr          n         y        n   
 survival         y         y        n   
 sys              n         y        n   
 tensor           n         y        n   
 tibble           n         y        n   
 tidyr            n         y        n   
 tidyselect       n         y        n   
 tinytex          n         y        n   
 trqwe            n         y        n   
 utf8             n         y        n   
 uwot             n         y        n   
 vctrs            n         y        n   
 vipor            n         y        n   
 viridis          n         y        n   
 viridisLite      n         y        n   
 withr            n         y        n   
 xfun             n         y        n   
 xtable           n         y        n   
 yaml             n         y        n   
 zoo              n         y        n  

I am pretty much at a loss as to how to move forward - any help would be much appreciated.

EDIT: Everything does seem to exist in;

 root@832a1d48a423:/project/renv/library/linux-debian-trixie/R-4.4/x86_64-pc-linux-gnu# ls /usr/local/lib/R/site-library
abind         ComplexHeatmap  farver        GlobalOptions  IRanges      memoise     promises       reticulate    shiny             tibble
askpass       cowplot         fastDummies   globals        irlba        mime        purrr          rjson         sitmo             tidyr
base64enc     cpp11           fastmap       glue           isoband      miniUI      R6             rlang         sourcetools       tidyselect
beeswarm      crayon          fitdistrplus  goftest        iterators    munsell     RANN           rmarkdown     sp                tinytex
BH            crosstalk       FNN           gplots         jquerylib    openssl     rappdirs       ROCR          spam              trqwe
BiocGenerics  curl            fontawesome   gridExtra      jsonlite     pak         RColorBrewer   rprojroot     spatstat.data     utf8
bitops        data.table      foreach       gtable         knitr        parallelly  Rcpp           RSpectra      spatstat.explore  uwot
bslib         deldir          fs            gtools         labeling     patchwork   RcppAnnoy      Rtsne         spatstat.geom     vctrs
_cache        digest          future        here           later        pbapply     RcppArmadillo  S4Vectors     spatstat.random   vipor
cachem        discovery       future.apply  highr          lazyeval     pillar      RcppEigen      sass          spatstat.sparse   viridis
caTools       doParallel      generics      htmltools      leiden       pkgconfig   RcppHNSW       scales        spatstat.univar   viridisLite
circlize      dotCall64       GetoptLong    htmlwidgets    lifecycle    plotly      RcppProgress   scattermore   spatstat.utils    withr
cli           dplyr           ggbeeswarm    httpuv         listenv      plyr        RcppTOML       sctransform   stringi           xfun
clue          dqrng           ggplot2       httr           lmtest       png         remotes        Seurat        stringr           xtable
colorspace    evaluate        ggrepel       ica            magrittr     polyclip    renv           SeuratObject  sys               yaml
commonmark    fansi           ggridges      igraph         matrixStats  progressr   reshape2       shape         tensor            zoo
kevinushey commented 4 months ago

What are the library paths when you are running with the container? It looks like your packages were installed into a system library path, whereas (I'm guessing) your regular R session is using a separate project-local library path.