-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate renv.lock file given a list of packages #89
Comments
This is the intended (default) behavior. From the Lines 237 to 243 in 85137ba
If you want to snapshot a specific library, you can do so:
It's not clear to me how snapshotting based on a package name only would work (how does |
@kevinushey That's awesome! For some reason that does not always work for me consistently. Locally that is working fine. If I try in a docker container, e.g.
(note this runs as root, and is just in working dir It looks like the default behavior grabs only the first library on |
What error are you seeing, exactly? This reminds me that when you try to snapshot an arbitrary library, we do attempt to filter what enters the lockfile based on what's used in the 'active' project (ie: current working directory) Lines 35 to 38 in 85137ba
The intention here was that you probably don't want everything in an arbitrary user library to enter the lockfile, but I don't think that matches your intent here.
It seems like we should do this. The main question here is: do we need to track which library a particular package dependency came from? Ie, if someone wants to call |
Running from root dir (
though this bug may be too much of an edge case to really worry about. Not sure why I don't get the error but also don't get my system library when running from root's home dir, Regarding which library to restore to, my take is that |
I've now implemented support for snapshotting multiple libraries -- something like:
should work as expected. Let me know if you bump into any issues. |
I'm going to close this; please open a new issue if you bump into other problems. Thanks! |
In case helpful, I came up with this one liner (to be run from the shell), that clears the renv.lock file, and regenerates it based on the dependencies listed in DESCRIPTION. But note! It will delete all installed packages from your local environment. Rscript -e 'if (file.exists("renv.lock")) {file.remove("renv.lock")}; remove.packages(installed.packages(priority="NA")[,1]); install.packages("renv", repos="https://cloud.r-project.org"); renv::settings$snapshot.type("explicit"); renv::install(library=tempdir(), lock=TRUE)' This makes it fairly close to Python’s requirements.in / requirements.txt pattern, JavaScript’s/Node’s package.json / package-lock.json pattern, and (I assume) Ruby’s Gemfile / Gemfile.lock pattern. (Because of the clearing of the lock file, there is no concept of “only upgrading certain packages and no others”, but I can live with that…) |
Apologies if this is out of scope, but I would love a way to give
renv
a list of bare package names and have it generate the correspondingrenv.lock
file (perhaps analogous to theGemfile
vsGemfile.lock
behavior in Ruby), e.g. something like:In which it would capture the listed packages and their dependencies (possibly configurable by
dependencies = c("Depends", "Imports", "LinkingTo", "Suggests")
?).This would also make it possible to create lockfiles for my full system (e.g. capture all the packages installed on a given Docker environment or VM, rather than just within a given project), with something like
snapshot(packages = installed.packages()[,1])
, which would be super useful to me.Thoughts? Maybe there is some way to approximate this behavior with a DESCRIPTION file but I haven't gotten that to work. (e.g. if I create a blank new project and add some dependencies to DESCRIPTION,
renv::dependencies()
detects them but currently they do not seem to get added to myrenv.lock
when I dorenv::snapshot()
??The text was updated successfully, but these errors were encountered: