You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Switch R version automatically when switching between RStudio projects that use renv #12622
Problem:
I work on a team with a mix of new and old projects, all of which use renv but many of which have different R versions (e.g., 3.6.3, 4.0.3, 4.1.3, and so forth). renv captures the R version and maintains the cache of packages. If you switch from an RStudio project using, say, 4.0.3 to a project using 3.6.3, you receive this little renv warning:
Warning message:
This project is configured to use R version '3.6.3', but '4.0.3' is currently being used.
* The project library is out of sync with the lockfile.
* Use `renv::restore()` to install packages recorded in the lockfile.
Unless you go to the trouble of reinstalling 4.0.3 versions of all packages (which itself creates reproducibility and lockfile issues), the best bet is to hold the Ctrl key (on windows) while restarting RStudio to pick 3.6.3, then re-navigate to the desired project. This little workflow is a little cumbersome even for experienced users and can be especially unclear to newer users of R/RStudio/renv.
Proposed solution:
When switching between RStudio projects (esp. in the upper-right hand dropdown box), RStudio should check the renv lockfile in the project folder/repo and see what version of R is snapshotted. If that version of R is available on the user's system, open a new RStudio window that uses that version of R (and/or prompt user to switch R versions when switching projects). This will avoid the warning message renv generates when loading a project with a different version of R, and avoid cumbersome restart issues that some users are not familiar with (holding Ctrl to select a specific version of R on RStudio startup). It will also avoid time consuming changes to restore packages and related confusion to the user.
Related tickets:
I did a scan of related tickets with renv and RStudio projects and did not find a match for this specific feature request.
Thanks for the great product.
Reacted by mattbewley, KyleHearing-FITP, stevenschrayer, Liam-Linhai Wu, Marco Alberti, Frank Aragona, Pasi Haapakorva and Hans Van Calster
@wtimmerman-fitp Thank you for the interesting suggestion! I'll tag this as a renv-related enhancement as we continue to develop RStudio. And thank you for the kind note!
Activity
ronblum commentedon Jan 24, 2023
@wtimmerman-fitp Thank you for the interesting suggestion! I'll tag this as a renv-related enhancement as we continue to develop RStudio. And thank you for the kind note!
wtimmerman-fitp commentedon Jan 24, 2023
Sounds great, thanks for considering it.
github-actions commentedon Jul 24, 2023
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.
github-actions commentedon Aug 8, 2023
This issue has been automatically closed due to inactivity.
ronblum commentedon Sep 30, 2025
Request raised on Bluesky in a discussion between a couple folks: https://bsky.app/profile/rbly.bsky.social/post/3lzzp3k7vec2b
warn when a project asks for a different r version, and offer to swit…
Remove duplicate NEWS entries for #12622, #19139, #19141
Update Electron to 44.9.3 (#19205)
keep a rig user-mode install from becoming the default R outside RStu…
undo rig's Windows default after a user-mode install as well (#19233)
pass install destination by name, refresh installs cache, lock dialog…
Offer R install and switch choices with destination confirmation (#19158