Skip to content

Instantly share code, notes, and snippets.

@philippmuench
Last active April 10, 2021 22:46
Show Gist options
  • Save philippmuench/a0135ac6e0ca9f502aad93cdf2ae8a45 to your computer and use it in GitHub Desktop.
Save philippmuench/a0135ac6e0ca9f502aad93cdf2ae8a45 to your computer and use it in GitHub Desktop.
packrat inside docker container
# add this line to your Dockerfile (you also need to install Rbase)
RUN R -e 'install.packages("packrat" , repos="http://cran.us.r-project.org"); packrat::restore()'
# on your local machine install packrat
if (!require("devtools")) install.packages("devtools")
devtools::install_github("rstudio/packrat")
library(packrat)
# if this not work set lib path and repro, and try again
# setRepositories(ind = c(1:6, 8))
# .libPaths( c("/path/to/your/R_library") )
# after installing, type in the following commands
packrat::init()
packrat::clean()
packrat::snapshot()
# then make sure the packrat.lock, packrat.opts, init.R
# is located in the packrat/ folder and push these files to the repo if necessary
@stephenhmarsh
Copy link

....oh, probably because using https throws and error:

Warning: unable to access index for repository https://cran.us.r-project.org/src/contrib:
  cannot open URL 'https://cran.us.r-project.org/src/contrib/PACKAGES'
Warning message:
package ‘packrat’ is not available (for R version 3.5.1) 

:P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment