Can someone clarify how the global cache differs from a project library in an renv? Does renv first search a project library, then the global cache?
1 Answers
The global cache is an implementation detail. It never determines what packages are part of the local library, and what gets loaded in a project.
The only importance of the global cache is, well, caching installed packages, which makes setting up a new project faster because, rather than having to download and install a package, ‘renv’ can just link the already installed, cached package into the local library:
Future calls to
renv::restore()
andrenv::install()
will become much faster, as renv will be able to find and re-use packages already installed in the cache.Because it is not necessary to have duplicate versions of your packages installed in each project, the renv cache should also help you save disk space relative to an approach with project-specific libraries without a global cache.
If you prefer, you can (mostly) ignore the existence of the global cache entirely. ‘renv’ should work as if it didn’t exist.

- 530,221
- 131
- 937
- 1,214
-
So the actual packages are stored in the cache, while the project library is ... what exactly? Looking at both the global cache and the library directories, I see the all the files for a given package are present. I guess I don't understand what renv is using when a project is restored. And if loading packages is faster when they are stored in cache, shouldn't that imply that the project library is unnecessary because everything needed to load a project is in the cache? – Rebecca Eliscu Jan 10 '22 at 22:25
-
@RebeccaEliscu For loading packages, ‘renv’ is always using the local library, never the cache. If you look at the paths in your local library they *should* all be symbolic links to the cache. However, it’s possible that you will see regular directories for the packages instead of symbolic links: this happens if linking the packages can’t be done for some reason: in this case, ‘renv’ copies the package directory from the cache into the local library. – Konrad Rudolph Jan 10 '22 at 22:32
-
@RebeccaEliscu “And if loading packages is faster” — It isn’t. Only *installing* the package is faster. – Konrad Rudolph Jan 10 '22 at 22:32