using `packrat::restore` in GitLab CI Docker container; order of entries in `packrat.lock` matters.
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 409
- Forks
- 89
- PR merge metrics
- No merged PRs in 30d
Description
My aim is to semi-reproduce the local (R) environment used for a complex analysis in a Docker container, so as to be able to share this with colleagues.
I am attempting to use packrat to produce a reproducible Docker container via GitLab CI ; I push packrat/packrat.lock, packrat/src, packrat/init.R and packrat/packrat.opts to the repository and build via GitLab CI; below is a snippet from my gitlab-ci.yaml file (set dry.run=TRUE is just for testing):
pages:
stage: build
image: rocker/hadleyverse:3.3.1
script:
- apt-get update && apt-get install -y tk8.5-dev tcl8.5-dev
- R -e "0" --args --bootstrap-packrat
- R -e 'packrat::restore(restart = FALSE, overwrite.dirty = TRUE, dry.run = TRUE)'
The issue is when using packrat::restore if a package has dependencies, and these are not entries in the list above the said package in the packrat.lock file, the build fails. For example, this fails with error The command failed with output: ERROR: dependencies 'pbkrtest' is not available for package 'car' :
Package: car
Source: CRAN
Version: 2.1-4
Hash: d8cc2f66d4ba0c91312f1c1c5773d502
Package: pbkrtest
Source: CRAN
Version: 0.4-6
Hash: 8117c37e2e3078e3c6465134bac6956e
Manually editing the order of entries in packrat.lock appears to be a fix for this issue, however when adding a new package and using packrat::snapshot(), packrat.lock is rewritten in previous order, meaning it is inconvenient. For example this packrat.lock seems to work:
Package: pbkrtest
Source: CRAN
Version: 0.4-6
Hash: 8117c37e2e3078e3c6465134bac6956e
Package: car
Source: CRAN
Version: 2.1-4
Hash: d8cc2f66d4ba0c91312f1c1c5773d502
I am new to packrat, so not sure if this is a real issue or maybe I am using the wrong approach or missing something? Any suggestions or good practices for dealing with (many) R package dependencies for automated Docker builds would be appreciated.
regards Ed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review packrat::restore and packrat::snapshot() behavior around the entries in packrat/packrat.lock, using the GitLab CI commands in gitlab-ci.yaml as the reproduction. Done means determining whether dependency order causes the reported failure and ensuring a snapshot-generated lockfile can be restored without manually reordering packages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, r
- Domain
- build-system, ci-cd, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100