Unfortunately, there isn't currently a direct way to replicate an
renv cache for a new version of R. Instead, I would recommend something like the following. For each project:
- Using R 4.1.x, call
renv::snapshot() to ensure the project lockfile is up-to-date
- Using R 4.2.x, call
renv::restore() to install the packages associated with each project.
Alternatively, if you felt comfortable building something by hand, you could use internal
renv APIs like
renv:::renv_cache_list() to find installed packages in the cache (for R 4.1.), and then devise a scheme to install those packages (via
renv::install() or similar).
Hopefully, this is something you'd be able to automate beforehand (to run on behalf of your users) so that this could be done in batch before the "official" migration. You might need to adjust the arguments provided to
restore() depending on how the migration is eventually structured; please see the documentation for more details.
That said, it's important to be aware that the versions of packages installed with R 4.1.x may or may not be functional with R 4.2.x. In such a case, it might be better to install the latest-available versions of the packages in use for a project, rather than the exact versions installed before. This is especially true if users are making use of packages from Bioconductor, as Bioconductor releases are normally intended to be used only for a particular version of R.
You might also want to consider allowing users to make use of a shared
renv cache. This can be done by setting the
RENV_PATHS_CACHE environment variable, to point to a shared directory location that is readable and writable by all users. See Introduction to renv • renv for more details.