Skip to content

Why doesn't packrat support running in packages? #31

Closed

Description

@dlebauer

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)?

Activity

  1. hadley commented on Dec 3, 2013

    @hadley
    Member

    I hope it's just a currently doesn't support too. I think packrat will be a great fit for package development.

  2. hadley commented on Dec 3, 2013

    @hadley
    Member

    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
  3. jmcphers commented on Dec 5, 2013

    @jmcphers
    Member

    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.

  4. dlebauer commented on Mar 5, 2014

    @dlebauer
    Author

    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.

  5. kevinushey commented on Jun 20, 2014

    @kevinushey
    Contributor

    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")

  6. denisesenguel commented on Apr 11, 2016

    @denisesenguel

    Any progress on this issue?

  7. kevinushey commented on Apr 11, 2016

    @kevinushey
    Contributor

    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!

  8. bperaHSA commented on Dec 10, 2016

    @bperaHSA

    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.)

  9. IsaacVerm commented on Mar 16, 2018

    @IsaacVerm

    What's the current status of packrat within packages?

  10. anhqle commented on Apr 24, 2018

    @anhqle

    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.

  11. dlebauer commented on Nov 7, 2024

    @dlebauer
    Author

    Closing b/c packrat is superseded by renv, and question is >10yo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions