RStudio keeps losing or forgetting installed packages

I work on a number of RStudio projects that manage their dependencies with renv. By and large this works swimmingly (although some of them seem to install a suspiciously large number of packages). The problem I keep running into is that my 'base' RStudio environment (i.e. without any actively loaded project) seems to keep forgetting or losing its installed packages.

I don't know how to go about providing a reproducible example for this but what'll happen is that I'll be in a project with renv that has the tidyverse installed. Then I want to mess around with something outside the project environment so I either close the project or start a new instance of RStudio with no active project. In some indeterminate number of cases, that base RStudio environment will tell me that packages I definitely installed are no longer installed.

This definitely seems to result from switching back and forth between renv-managed and non-renv-managed environments but I can't figure out why it's occurring. Has anyone else seen anything like this?


Hi Mykle,

I don't know if I can exactly help with this answer, because I don't know the library renv but sometimes I think that something similar happen when the library path is in a cloud synced folder.

Hope it helps.


What does renv do, for any project it manages the installation of packages for that project (and wont provide them for other projects / or the 'no project' state. )
On the plus side, when it is used it places the package into a cache so when it is asked to install the same package(and version) into a second project ( or the no project general state) it can do this rapidly by linking to the cache.
i.e. use renv::install() in your non project context to provide the packages you need in your non project context, when they are packages you used previously in some project and assuming the cache is working correctly, this should be rapid.

1 Like

That's a good point. At least if I find myself in these circumstances it'll install quickly. Thanks!

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.