Using renv to manage the package library in RStudio Cloud, the status of the library is broken when sharing the project. This is because renv uses a global package cache and the local packages are only links. When the project is shared, the new user will not have the proper package cache and thus all the links start broken.
The user experience is that if I want to share a project that uses renv in Rtudio Cloud, the recipient has to run renv::repair(), which can be confusing and take a long time. Compared with the experience of not using renv, in which required packages are come installed with the project, it's much worse, particularly for teaching and short workshops.
I raised the issue in the renv repo too and @kevinushey recommended setting the global cache to inside the project by setting the RENV_PATHS_CACHE environmental variable to renv/cache.
I haven't tested this but I guess it should work (although I don't know how well it would play with cloud's size limits!).
@kevinushey also said:
The downside to using a project-local cache, of course, is that the cache would no longer be visible in your other projects, since the cache would be bound to the project instead of your user account... so choosing the cache location requires some care here.
Ideally, the cache would be visible to:
- The user (or users) who need to access the shared project,
- Users who need to use the
renv cache even outside of a particular shared project.
But I'm not sure if RStudio Cloud has any notion of such persistent shared storage.
So I guess:
- What's the best way of using renv with RStudio Cloud that's friendly with sharing projects? Is
RENV_PATHS_CACHE = renv/cache the best workaround?
- Is there something that can be changed either in RStudio Cloud or renv (or both?) to make this work painlessly?