R In Rstudio Server renv not keep activated

137 views Asked by At

The question is very important for us. We installed renv in our server's Rstudio Server. And propose to use it for every project. In order to see if that works for the team, I made the first attempt. Although the Server keeps on running(we didn't terminate R session if we leave work every day.) but next day when I come back to work, I often see the renv is not activated any more. (e.g. When I use renv::hydrate() it tells me the renv is not yet activated in this project, so the status is different from yesterday).

I don't want this because,if I want to use renv I need to activate it every time,it will restart the whole r session,it took time and may lead to some other unexpected result or status.

I guess the reason: 1 Although we didn't manually terminate Rstudio Server, it actually restarted during standby at night. 2 Some unknown process stopped renv from activated status.

Anyone knows the solution or reason is welcomed.

1

There are 1 answers

0
Marja van der Wind On

As @Niklas pointed out in the comments, Renv is a collection of files. Renv works with a lockfile to snapshot() and status() your list of packages and also restore() it if needed. (Source)

This file is in use almost all the time. The description of your problem suggests to me that your project is saved in a cloud service such as OneDrive or Dropbox. The synchronisation of this file will fail all the time, but is probably being pushed through at midnight. Changing the lockfile in the source while the project is still running, may cause problems.

The solution would be to save your project not in a cloud location. (This is highly recommended as Git does not work well with OneDrive or Dropbox anyway and Git is a better way of tracking changes in code and sharing code). Otherwise, exclude your lockfile from the synchronisation step in your cloud app. (This is easier)