I am getting started with collaborating with team members on R projects using renv. While I can (mostly) get it to work, I am a bit confused about whether and where to install renv itself. According to the documented workflow I basically need renv installed before I start a new project with renv.
However, when I do not have renv installed, and clone a repo that uses renv, it seems to install (bootstrap?) itself. But it does this within the local renv environment.
I have a couple of questions regarding this:
- Do you recommend to have
renvinstalled "outside" therenvvirtual environment? - How do you deal with differences in versions of
renvitself between what is e.g. installed on my machine and present in a repo that I clone, and whichrenvI would like to replicate? I ran into problems with this one, could not replicate arenvfrom a cloned repo with a differentrenvversion. - On a more conceptual level: why is
renvitself part of the virtual environment it creates? That's not the case for the python virtual environment managers I know.
We do. In fact, this is necessary if you want to initialize an
renvproject in the first place, since this is done by callingrenv::init()-- and so the regularrenvinitialization workflow expectsrenvto be installed into the user library.Since
renvis just an R package, you can install or upgrade (or downgrade) the version ofrenvused within a project as required, without affecting other projects. For example, installing the latest version from CRAN can be done with a plaininstall.packages("renv").When working within an
renvproject, the version ofrenvinstalled in that project is normally the copy that is used -- so at this point, it should no longer matter what version ofrenvis installed in the user library.This is done primarily to ensure existing
renvprojects can continue to function even if an update torenvhappened to break some existing workflows. (We endeavor to make sure that will never happen, but want to make sure users have an escape hatch in case it does.)The "bootstrap" behavior here is done to help streamline the collaborative workflow. Rather than requiring users explicitly install
renvbefore opening anrenvproject,renvknows enough to bootstrap itself in an existing project so that new users can get up and running quickly. (In addition, the bootstrapper script also tries to ensure that the version ofrenvthat project was configured to use is installed.)