How to update the version of R used within a project, using renv
Asked Answered
M

1

8

I have a project that used R 3.6, I have upgraded R to 4.0.2 and would like to use 4.0.2 for this project. I'm wondering how to go about doing so, or should I completely delete renv/ and rebuild?

Edit

I have done the following:

> renv::init()
This project already has a lockfile. What would you like to do?

1: Restore the project from the lockfile.
2: Discard the lockfile and re-initialize the project.
3: Activate the project without snapshotting or installing any packages.
4: Abort project initialization.

And selected 2 from the above, this seems to be reasonable.

Mcmahon answered 2/9, 2020 at 11:9 Comment(0)
G
4

Different versions of R will get their own independent project libraries, so technically speaking you can use different versions of R with the same renv project.

That said, each project only has a single lockfile -- to update the lockfile, you can either call renv::snapshot() to create a brand new lockfile, or re-initialize the project with renv::init() (as you've done) -- both are correct.

Glob answered 6/9, 2020 at 4:28 Comment(3)
Thanks, I'm not sure that I fully understand what you mean in the first paragraph. Different R versions (on system) will have different project libraries (so dplyr for 3.6.2 will be different to dplyr for 4.0.2 I presume). If you have any documentation for this it'd be good for me to be able to skim, thanksMcmahon
so if there is only one lock file, and only one R version is recorded in the lock file, wouldn't there be package clashes between different versions of R?Dustidustie
Yes. The intention (in general) is that a particular project should be tied to a single version of R. If you want to associate a project with multiple versions of R / multiple libraries / multiple libraries, then you might want to use the profiles feature in renv 0.13.0: rstudio.github.io/renv/articles/profiles.htmlGlob

© 2022 - 2024 — McMap. All rights reserved.