Why is it sufficient to just commit renv.lock?

I have a project that uses renv inside GitHub Actions as described here. For the bookdown Actions example, which uses renv, I see:

You will need to run renv::snapshot() locally and commit the renv.lock file before using this workflow...

Why is renv.lock sufficient? Why am I allowed to omit .Rprofile and renv/activate.R? As expected, when I delete .Rprofile locally, the renv library does not load. So then why do GitHub Actions workflows like this one complete without error?

Because the renv package bootstraps itself if the library is not setup yet. e.g. delete both .Rprofile and renv from your project and then run install.packages("renv"); renv::restore() on it.

1 Like

It did not occur to me that renv::restore() would ever write to the global package library. I always assumed the library had to be renv/library/. Makes sense now why no .Rprofile is needed. This is super useful!

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.