rstudio / packrat

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

Dependencies on external packages cause error during snapshot #536

Open brendanf opened 5 years ago

brendanf commented 5 years ago

I'm using packrat 0.5.0 and R 3.5.0. It seems like installing a package to the packrat library which depends on a package which has been declared "external" causes an error on the next snapshot.

Starting in an empty project directory:

packrat::init()
Initializing packrat project in directory:
- "~/packrat-test"
--- Please select a CRAN mirror for use in this session ---

Adding these packages to packrat:
            _      
    packrat   0.5.0

Fetching sources for packrat (0.5.0) ... OK (CRAN current)
Snapshot written to '/home/brendan/packrat-test/packrat/packrat.lock'
Installing packrat (0.5.0) ... 
    OK (built source)
Initialization complete!
Packrat mode on. Using library in directory:
- "~/packrat-test/packrat/lib"
> packrat::set_opts(external.packages="dplyr")
> install.packages("assertr")
Installing package into ‘/home/brendan/packrat-test/packrat/lib/x86_64-pc-linux-gnu/3.5.0’
(as ‘lib’ is unspecified)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 97897  100 97897    0     0   303k      0 --:--:-- --:--:-- --:--:--  302k

Attaching package: ‘dplyr’

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

* installing *source* package ‘assertr’ ...
** package ‘assertr’ successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (assertr)

The downloaded source packages are in
    ‘/tmp/Rtmp6ofZky/downloaded_packages’
> packrat::snapshot()
Error: Unable to retrieve package records for the following packages:
- 'dplyr', 'rlang'

I ran the debugger on snapshot(). There is a call to getPackageRecordsExternalSource() whose name suggests it should be taking care of finding the package records for external sources... but it is passed the packrat library directory (packrat/lib/<architecture>/<version>) instead of the external package library directory (packrat/lib-ext/<architecture>/<library>) as lib.loc, so of course it can't find them.

Does this work for anyone?

rpodcast commented 5 years ago

I wish I had the solution, but the same thing just happened to my project using R 3.5.2 and packrat 0.5.0.

In my case I installed a package called ggfan which imports rstan. I have to commit the packrat package library directories to my git repo due to an internal pipeline requirement, and I had to set rstan to external since compiling it from source brings a whopping 220 MB complied .so file, which can't be committed to GitHub due to size restrictions. Now I am trying to add new packages to the packrat lib but I am also getting the unable to retrieve package records error for rstan. This is driving me pretty bonkers!