You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why doesn't packrat support running in packages? #31
I have gotten in the habit of using the R packaging system to organize projects. I put scripts in a folder such as vignettes, scripts, or inst/manuscript. I wanted to test out using packrat and encountered the "Packrat doesn't work when the packages." message from the bootstrap function. Is this to be read "Packrat is not intended to work on packages" or "Packrat does not currently support packages"? I read the documentation and did not find any mention of support for use with packages, and can not understand why this would be disabled by default.
If there is a reason for not using it in the package root directory, would you recommend that I bootstrap directories within the package (like the vignettes folder)?
Here's a concrete scenario where I'd find it particularly useful. @romainfrancois and I are working on the dplyr package which uses Rcpp. Romain is also working on Rcpp. If Romain installs the development version of Rcpp to test it, then it's easy to accidentally use it when working on packrat. Then the code might not work on my computer because I'm using the CRAN version of dplyr.
Other thoughts on using packrat with packages:
need to use a different strategy for determining which packages to install - just look in the description
it's particularly important to identify if the local packages are out of date
what should build and reload do? Using the local library would be nice because it would isolate effects from the system, but packrat would need to ignore that package when generating a lock file, messages etc. You'd also want some way to override that choice
packrat specific files and directories should be automatically added to .Rbuildignore
would making testing with travis easier since you'd already have all the correct packages - but might need some tweaks to the install priorities. Not sure if the package isn't available in the local library whether you prefer the globally installed version or the cached src, but using the global library would make it possible to take advantage of prebuilt binaries
As @hadley notes, there's some work involved in making packrat a really good tool for package authors, and for the initial release we didn't have the resources to take that on, so we explicitly discouraged it. (Very early versions of Packrat also used DESCRIPTION for the lockfile, so we also had to make sure we didn't clobber a package DESCRIPTION!).
Packrat looks for a DESCRIPTION file to determine if it's being invoked on a package, but it only does this check once, during bootstrap, so it's easy to circumvent if you want to try it--just be aware that it's a largely untested scenario.
There's been a lot of work done to help support the integration of packrat with R package development workflows; in particular, the new external.packages option added gives a means of loading packages from the user library while performing package development.
This is useful as it gives you a means of using e.g. devtools while working on a package that does not explicitly require devtools, while allowing packrat to manage the private library (e.g. with a local version of Rcpp from GitHub, for example).
Package installs will also go into this private library, giving a sandbox for testing of the package (but we need a way of saying, "install this package in the user library now")
There has been substantial progress on using packrat within the context of R package development, but there may yet be some edge cases to resolve (especially in the context of using packrat + R package + RStudio all together). Feel free to give it a whirl and raise an issue if you have trouble!
I'm having trouble with devtools::load_all(). Namely, that it is not attaching the imports in my NAMESPACE file to my namespace. My suspicion is that it is related to packrat. I had also cleaned up the /R directory with formatR shortly before the problem appeared.
For now I'm stuck using Depends instead of Imports in my DESCRIPTION file and/or using package:: prefixes only. Not a terrible workaround but not a best practice either which is rather irritating. I wonder if anyone else has come across the issue or if anyone has hints for me to try.
(I already reset my project back via git to the last commit before the formatR tidy_dir and the problem still persists. Also, my NAMESPACE file is being created by roxygen.)
I'm using packrat fine during package development. I just had to set infer.dependencies = FALSE in packrat::init() and manually install the dependencies with the correct versions. It seems that packrat does not infer dependencies from the DESCRIPTION file yet, and instead search for library() and required() in R scripts.
Activity
hadley commentedon Dec 3, 2013
I hope it's just a currently doesn't support too. I think packrat will be a great fit for package development.
hadley commentedon Dec 3, 2013
Here's a concrete scenario where I'd find it particularly useful. @romainfrancois and I are working on the dplyr package which uses Rcpp. Romain is also working on Rcpp. If Romain installs the development version of Rcpp to test it, then it's easy to accidentally use it when working on packrat. Then the code might not work on my computer because I'm using the CRAN version of dplyr.
Other thoughts on using packrat with packages:
jmcphers commentedon Dec 5, 2013
As @hadley notes, there's some work involved in making packrat a really good tool for package authors, and for the initial release we didn't have the resources to take that on, so we explicitly discouraged it. (Very early versions of Packrat also used DESCRIPTION for the lockfile, so we also had to make sure we didn't clobber a package DESCRIPTION!).
Packrat looks for a DESCRIPTION file to determine if it's being invoked on a package, but it only does this check once, during bootstrap, so it's easy to circumvent if you want to try it--just be aware that it's a largely untested scenario.
dlebauer commentedon Mar 5, 2014
I am just starting to experiment with adding packrat explicitly to the vignettes folder
packrat::bootstrap("path/to/mypackage/vignettes/")It seems that I could suffer from circular logic, but for now it seems to be useful.
kevinushey commentedon Jun 20, 2014
There's been a lot of work done to help support the integration of packrat with R package development workflows; in particular, the new
external.packagesoption added gives a means of loading packages from the user library while performing package development.This is useful as it gives you a means of using e.g.
devtoolswhile working on a package that does not explicitly requiredevtools, while allowingpackratto manage the private library (e.g. with a local version ofRcppfrom GitHub, for example).Package installs will also go into this private library, giving a sandbox for testing of the package (but we need a way of saying, "install this package in the user library now")
denisesenguel commentedon Apr 11, 2016
Any progress on this issue?
kevinushey commentedon Apr 11, 2016
There has been substantial progress on using packrat within the context of R package development, but there may yet be some edge cases to resolve (especially in the context of using packrat + R package + RStudio all together). Feel free to give it a whirl and raise an issue if you have trouble!
bperaHSA commentedon Dec 10, 2016
I'm having trouble with devtools::load_all(). Namely, that it is not attaching the imports in my NAMESPACE file to my namespace. My suspicion is that it is related to packrat. I had also cleaned up the /R directory with formatR shortly before the problem appeared.
For now I'm stuck using Depends instead of Imports in my DESCRIPTION file and/or using package:: prefixes only. Not a terrible workaround but not a best practice either which is rather irritating. I wonder if anyone else has come across the issue or if anyone has hints for me to try.
(I already reset my project back via git to the last commit before the formatR tidy_dir and the problem still persists. Also, my NAMESPACE file is being created by roxygen.)
IsaacVerm commentedon Mar 16, 2018
What's the current status of packrat within packages?
anhqle commentedon Apr 24, 2018
I'm using
packratfine during package development. I just had to setinfer.dependencies = FALSEinpackrat::init()and manually install the dependencies with the correct versions. It seems thatpackratdoes not infer dependencies from theDESCRIPTIONfile yet, and instead search forlibrary()andrequired()in R scripts.dlebauer commentedon Nov 7, 2024
Closing b/c packrat is superseded by renv, and question is >10yo