rstudio/renv

Restore should consider uncached system/user library packages

Closed this issue · 3 comments

When initializing an renv environment in a fresh R setup, hydrate recycles packages from e.g. user or system libraries (i.e. puts them to the cache). This seems particular useful with heavily prepackaged Docker images such as rocker/tidyverse. However, these packages are reported with CRAN sources in the lock file, as mentioned here.

So when restoring the renv in another fresh R setup (same conditions and version, e.g. by using the same Docker image), all locked packages will be installed from CRAN. Although many of them could have been recycled from the local libraries again, which would save time and data transfer volume. This kind of defeats the purpose of more extended prepackaged Docker images.

Would it be possible for restore to draw packages from local sources first (if version/hashes match) similar to as hydrate does? Or to have a function that puts local packages into the cache which could be run before restore?

My current workaround is to use hydrate to populate the cache with local packages (but which then already downloads everything else, not necessarily in the finally required version) and then restore to make sure each package is in the right version. But this is also redundant and not time and data transfer friendly.

This seems like a good idea to me as well -- no reason to download and install packages if there's already a good copy available locally.

I've now made this change on master:

462bea8

If you get a chance, please give this a test and let me know if you see any issues. Thanks!

Just wanted to get back to you. Seems to work. That's really useful. Thanks a lot!