Packrat bundles with different R versions - suggestions and alternatives

June 13, 2019 @adomingues Antonio Domingues

@adomingues wrote:

Hi all,

I am looking into packrat as a way of keeping things from breaking when updating / installing packages for a particular project. A typical situation would be that a new package needs to be installed but requires some dependencies to be upgraded / installed, which then will break existing code. It is particularly common with Biocondiuctorpackages. It is also an issue for us because quite some projects take years before completion, sometimes spanning several R / BioC versions.

What did I actually do? Bundle creation:

  • on my local computer (OSX, fresh install), installed R 3.6 and multiple R and BioC packages
  • Started a new project with packrat::init()
  • Created a snapshot with packrat::snapshot()
  • And finally a bundle with packrat::bundle(), which I think includes all package sources as well.

Project restoration:

  • On a server, R version 3.5.1 and CentOS Linux 7, I unbundle the bundle and got the following error
> packrat::unbundle("test_packrat-2019-06-11.tar.gz", "./")
- Untarring 'test_packrat-2019-06-11.tar.gz' in directory '/lustre/projects/bioinfo/domingue/scripts'...
- Restoring project library...
Installing BH (1.69.0-1) ... 
        OK (built source)
Installing BiocGenerics (0.30.0) ... 
Error: Command failed (1)

Failed to run system command:

        '/sw/apps/r/3.5.1/lib64/R/bin/R' --vanilla CMD INSTALL '/tmp/RtmpvUnPCU/BiocGenerics' --library='/lustre/projects/bioinfo/domingue/scripts/test_packrat/packrat/lib/x86_64-pc-linux-gnu/3.5.1' --install-tests --no-docs --no-multiarch --no-demo 

The command failed with output:
ERROR: this R is version 3.5.1, package 'BiocGenerics' requires R >=  3.6.0
In addition: Warning message:
In restore(project = getwd(), restart = FALSE) :
  The most recent snapshot was generated using R version 3.6.0

So as far as I can tell I am running into an issue, sort of unsurprisingly, of R / BioC packages not compiling in a different R version.

The questions are now:

  1. How to overcome this issue short of creating a docker container for every project?
  2. Is there a better way of keeping R workflows from breaking when R or it's packages are updated? I am thinking something like virtualenvs in python would work (python + packages for each project), but I am not sure something like this exists in R.

Regarding 2, I am guessing snapshots will tell me which version the packages where before updating, but I don't know if it would be easy to restore in case of an R update.

Cheers!

Posts: 8

Participants: 4

Read full topic

Previous Article
Plumber API + Scheduled RMarkdown ETL
Plumber API + Scheduled RMarkdown ETL

@jeff.keller wrote: I quite like the simplicity of using scheduled RMarkdown doc...

Next Article
Oauth2 authentication
Oauth2 authentication

@wsgomaa wrote: Dears, Can I use Oauth2 authentication in RStudio Connect to aut...