packrat workflow?

packrat

#1

Split from Are packrat bundles really portable across different platforms?


What would the workflow look like, if I only wanted a few packages to be included in packrat/src directory?

Say, I wanted to snapshot a a custom library on project level, because it changes a lot and I don't want to break code.

Is it possible to save the sources only of some of the packages?


Are packrat bundles really portable across different platforms?
#2

I think you could you the local.repo functionality of packrat. If you put the the src in a folder inside your project as folder or tarball, and set the option local.repos to that folder, that should work.
I used it for custom :package: not on CRAN that I wanted to include in the bundle.


#3

Will this also allow me to record/lock the current versions of say the tidyverse, but not download and persist the sources of these packages?

Ideally I would want to have a complete packrat.lock-file and a small packrat/src-directory, which only holds libraries that cannot easily be downloaded from CRAN.

These will then be committed and should most likely enable a reproduction of the project-library when the project is cloned.


#4

You can disable download sources of :package: in packrat option. The version will be registered in the lock file but the tarball won't be downloaded into the project folder.
You also have an option to ignore src directory from git.

Yes you can do that.

Tell me if you need help setup the options in your packrat project.


#5

Thank you so much!

But can I have both? A "downloaded" src for some (local or not) repos and just the recorded library state in packrat.lock for the others? (When I disable package downloads globally, than the few packages I want to store won't be downloaded as well, right?)

Downloading everything and only committing the sources seems like an option, though I would rather "opt-in" to storage of the sources/libraries than "opt-out".


#6

I do not think you can have both. Packrat allow to use CRAN repo or CRAN-like repo, some remote source (like GH) or to have a local directory of :package: sources.

You can disable all package download to a src project folder with snapshot.sources = FALSE in argument or as packrat option. By default it is TRUE.

By default, you can also ignore some folder from control version : vcs.ignore.src and vcs.ignore.lib. The second is TRUE by default, but the first one is FALSE. So :package: src are in git repo by default but not :package: installed library folders.

About local repository, it is explained in the README. packrat::set_opts(local.repos = ...) allows you to set up the repo, and all packages installed by packrat::install_local(), they will be restored from the local.repos folder.

You cannot select some of the :package: to not be downloaded and others to be downloaded. However, you can set up in the local.repos directory the :package: you want to be present and disable download from CRAN for other. However, this is a manual step to set up the local repos (a helper function could be useful here to download and untar the src in folders).

Reminder: the options of packrat can be set as global through options or environment variable. You can then change the default on you system. Otherwise, it could be local to the projet through the packrat.opts file that you can put on git source tracking like the lockfile.

Hope it helps.


#7

The other concept potentially worth including here is the idea of "External packages." These packages will not be managed by packrat at all (i.e. will not be in the lockfile, no sources, etc.). They are helpful in cases that you want packrat to just depend on the package being available at the system level, independent of the project. Not sure if that is helpful in this context or to what you are trying to accomplish, but wanted to mention it just the same.