renv
is a package to manage locally packages library by projet. renv
is:
Isolated: Installing a new or updated package for one project won’t break your other projects, and vice versa. That’s because renv gives each project its own private package library.
Portable: Easily transport your projects from one computer to another, even across different platforms. renv makes it easy to install the packages your project depends on.
Reproducible: renv records the exact package versions you depend on, and ensures those exact versions are the ones that get installed wherever you go.
https://rstudio.github.io/renv/index.html
The general workflow for renv is:
Initialise the project with renv::init
. It creates a new renv directory inside the project and a .Rprofile to activate renv when is launched. A the begining this library contains only base packages.
Work as usual, installing and removing packages as needed.
Call renv::restore()
to save the state of the current library environment. This populate the renv.lock file with the version and source of each package.
To reproduce the environment (re-installing the same packages) we only need to keep the renv.lock file. The function renv::restore()
will restore the state from this lockfile.
By default, renv installs package in a cache (location varies according to OS) and then only create links from this cache to the project library.
Cache location:
Platform | Location |
---|---|
Linux | ~/.local/share/renv |
macOS | ~/Library/Application Support/renv |
Windows | %LOCALAPPDATA%/renv |
The cache can be shared accross users.
python is supported through reticulate
and the creation of a virtual env.