packrat::init fails with an Rcpp package installed using devtools::install_github
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 409
- Forks
- 89
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
Not sure what to title this issue since I haven't quite isolated the problem. I have, however, been able to reproduce it.
Packrat seems to fail when working with packages I have installed from github & which have compiled sources. These packages (because they are compiled) also tend to be installed with particular args passed to the command to devtools::install_github. I have finally also found that a restart of the R process after installing is usually necessary before loading the package.
One of these steps in the above is likely responsible for the failure to cleanly initialize a project using packrat where just such a package has been included in the snapshot.
I have set up an example repo to illustrate the issue here.
For example, say I have cloned this repo (here I am cloning into another directory, to not conflict with that in which I created the repo):
git clone git@github.com:jburos/test-packrat-restore.git test-packrat-restore-v2
cd test-packrat-restore-v2
R
I would see:
[ ... ] ## running `source("packrat/init.R")`
Installing colourpicker (0.3) ...
OK (built source)
Installing shinystan (2.3.0) ...
OK (built source)
Installing rstanarm (2.13.1) ...
Error: Command failed (1)
Failed to run system command:
'/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/Rtmpx1OFWx/stan-dev-rstanarm-db6974c' --library='/home/jacquelineburos/projects/test-packrat-restore-v2/packrat/lib/x86_64-pc-linux-gnu/3.3.2' --install-tests --no-docs --no-multiarch --no-demo
The command failed with output:
* installing *source* package 'rstanarm' ...
** libs
** R
** data
*** moving datasets to lazyload DB
** exec
** inst
** tests
** preparing package for lazy loading
** help
No man pages found in package 'rstanarm'
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in library.dynam(lib, package, package.lib) :
shared object 'rstanarm.so' not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/home/jacquelineburos/projects/test-packrat-restore-v2/packrat/lib/x86_64-pc-linux-gnu/3.3.2/rstanarm'
Note that the code I used to install rstanarm is as follows (included in the repo as example_script.R):
install.packages('devtools')
library(devtools)
if (!require('rstanarm')) {
devtools::install_github('stan-dev/rstanarm', ref='feature/jm', args='--preclean', local=FALSE)
library('rstanarm')
}
After that, I ran packrat::snapshot(), committed changes & pushed to the github repo.
I would also note, upon "trying again" (IE quitting & restarting R in the same session), I see the following:
jacquelineburos@jacki2:~/projects/test-packrat-restore-v2$ R
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Packrat mode on. Using library in directory:
- "~/projects/test-packrat-restore-v2/packrat/lib"
> library(rstanarm)
Error in library(rstanarm) : there is no package called ‘rstanarm’
> packrat::status()
The following packages are used in your code, tracked by packrat, but no longer present in your library:
from to
rstanarm 2.13.1 NA
Use packrat::restore() to restore these libraries.
However, running packrat::restore() would yield the same error message as was included above.
In practice, this leads to unexpected & confusing behavior in a real-world scenario since in practice I would normally have several packages that would not have been installed after the error initializing & no way to trigger their reinstall. I am also quite hesitant to direct a colleague to use this repository without explanation.
As it stands, the best work-around I have found to use this type of package with packrat is to include each of these packages in the ignored.packages list & modify the .Rprofile to include a script to install it manually, as done above. Any other are suggestions welcome.
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
Reproduce the failure using the linked test-packrat-restore repository and example_script.R, then compare source("packrat/init.R") with packrat::restore() for the compiled GitHub package. Trace the failed installation and document the cause; done means initialization or restore completes and the tracked package is available in the packrat library.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100