Skip to content

Switch R version automatically when switching between RStudio projects that use renv #12622

Description

@wtimmerman-fitp

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.

Activity

  1. added
    new
    on Jan 24, 2023
  2. ronblum commented on Jan 24, 2023

    @ronblum
    Contributor

    @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!

  3. added and removed
    new
    on Jan 24, 2023
  4. wtimmerman-fitp commented on Jan 24, 2023

    @wtimmerman-fitp
    Author

    Sounds great, thanks for considering it.

  5. github-actions commented on Jul 24, 2023

    @github-actions

    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.

  6. added
    stale
    on Jul 24, 2023
  7. github-actions commented on Aug 8, 2023

    @github-actions

    This issue has been automatically closed due to inactivity.

  8. ronblum commented on Sep 30, 2025

    @ronblum
    Contributor
  9. removed
    stale
    on Sep 30, 2025
  10. added this to the Product Backlog milestone on Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions