renv puts all packages into project's renv/library

Hello,

We are a small team that uses RStudio/R on windows 10 machines with shared network drives. Our R projects are on such a shared network drive so that everyone can access them. I recently discovered renv and thought that that would be useful for us.

I think it would be a good idea to keep all packages (normal installs from CRAN repo) in a folder on the shared network drive. So I have set RENV_PATHS_ROOT = "A:/ ... /external" in my Rprofile.site but when I install a package, it is not only put there but also into the projects "renv/library" folder. That results in the fact that all projects are relatively large as they contain all the packages. To my understanding the packages should be only kept in one central place (is this refered to as the renv cache or as renv global?)

So my question is:
What has to be done so that the packages are not stored individually per project?

BTW, I have found different information on the renv github pages:

https://rstudio.github.io/renv/articles/renv.html
"If you’d like to share the package cache across multiple users, you can do so by setting the RENV_PATHS_CACHE environment variable to a shared path."

https://rstudio.github.io/renv/reference/paths.html:
If desired, this path can be adjusted by setting the RENV_PATHS_ROOT environment variable. This can be useful if you'd like, for example, multiple users to be able to share a single global cache.

Thanks for your help in advance!

Sorry for taking so long to respond; I've been out of office for the past couple weeks.

Right now, the cache is disabled by default on Windows. This is because the cache uses junction points, which typically only work across NTFS filesystems, which may not work in all environments (especially in those where networked filesystems are used).

You can try running:

renv::settings$use.cache(TRUE)

in any project where you'd like to make use of the global cache. See ?renv::settings for more details.

I'm hoping to explore whether renv could be 'smarter' here -- e.g. attempt to use the cache and form junction points if possible, and fall back to copies or similar when not.

(In theory, it's also possible to enable and use symlinks on newer versions of Windows, but I ran into various kinds of errors and surprises when first exploring that as well.)

Thanks for your response :slight_smile:

In the meanwhile I have something working by setting
RENV_PATHS_ROOT
RENV_PATHS_CACHE
RENV_PATHS_LIBRARY
all to our shared directory.

That created the following folders in the shared directory:
R-3.6/x86_64-w64-mingw32
source/repository
v5/R-3.6/x86_64-w64-mingw32

No packages are in the renv/library folders of my projects...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.