Collaborating with renv

When you want to share a project with other collaborators, you may want to ensure everyone is working with the same environment – otherwise, code in the project may unexpectedly fail to run because of changes in behavior between different versions of the packages in use. You can use renv to help make this possible.

Collaborating with renv

When using renv, the packages used in your project will be recorded into a lockfile, renv.lock. Because renv.lock records the exact versions of R packages used within a project, if you share that file with your collaborators, they will be able to use renv::init() to initialize your project with exactly the same R packages as recorded in the lockfile. This implies the following workflow for collaboration:

  1. Select a way to share your project sources. The recommended way to do so is with a version control system alongside a public repository; e.g. git with GitHub, but many other options are available.

  2. Make sure your project is initialized with renv by calling renv::init().

  3. Share your project sources, alongside the generated lockfile renv.lock.

After your collaborators have received your renv.lock lockfile, they can then also execute renv::init() to initialize their project with the packages declared in that lockfile into their own private project library. By doing this, they will now be able to work within your project using the exact same R packages that you were when renv.lock was generated.

For more information on collaboration strategies, please visit

Updating the Lockfile

While working on a project, you or your collaborators may need to update or install new packages in your project. The workflow remains the same as before – after installing these new packages, you can share the updated lockfile with your collaborators, and request that they execute renv::init() to synchronize their library with the lockfile. Or, if the project has already been initialized on their machine via a prior call to renv::init(), then they can simply execute renv::restore().

A bit of care needs to be taken if your collaborators attempt to update packages independently. It is recommended that a single ‘source of truth’ is used for the package sources and renv.lock, to avoid different collaborators ending up with different lockfiles – or even, different versions of the project sources!

The simplest way to guard against this it to use a version control system, and have all collaborators work off the same branch. This way, if someone needs to update renv.lock in the public repository, all collaborators will see that updated lockfile and will gain access to it next time they pull those changes. Depending on the size of your team, you may want to ensure any changes to renv.lock are communicated so that everyone knows and understands when and why packages have been installed or updated.