Skip to content

Opening a new project with renv selected causes an incorrect lock file to be generated #14526

Open

Description

@samcofer

System details

RStudio Edition : Posit Workbench 2023.12.1+402.pro1, “Ocean Storm” (2d0df08b)
RStudio Version : 2023.12.1 Build 402.pro1
OS Version      :  Ubuntu 22
R Version       :  4.2.3 and 4.0.5

Steps to reproduce the problem

  1. Create a new project in RStudio using File -> New Project -> New Directory -> New Project, give the project a name and select R version 4.2.3.
  2. Once that project has opened, select File -> New Project -> New Directory -> New Project, give the name this project "test" and select R version 4.0.5
  3. You should then get this informational test in the R Console before the new project opens:

The following package(s) will be updated in the lockfile:

# RSPM -----------------------------------------------------------------------
- renv   [* -> 1.0.2]

The version of R recorded in the lockfile will be updated:
- R      [* -> 4.2.3]

- Lockfile written to "~/test/renv.lock".
  1. When the new "test" project loads, the following information is captured in the R console:
# Bootstrapping renv 1.0.2 ---------------------------------------------------
- Downloading renv ... OK
- Installing renv  ... OK

ℹ Using R 4.0.5 (lockfile was generated with R 4.2.3)
- Project '~/test' loaded. [renv 1.0.2]

As you can see, there is a mismatch between the contents of the lockfile, because it's written by renv::init() using the old version of R the definition of the project which should be using R 4.0.5.

Describe the problem in detail

The problem is that RStudio is running renv::init() on the new project prior to loading the projects selected version of R.

Describe the behavior you expected

RStudio should likely not run renv::init() until the new version of R has started and is running in the session.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    new
    on Apr 9, 2024
  2. samcofer commented on Apr 9, 2024

    @samcofer
    ContributorAuthor
  3. added and removed
    new
    on Apr 10, 2024
  4. added this to the Product Backlog milestone on Apr 22, 2024
  5. kevinushey commented on Apr 22, 2024

    @kevinushey
    Collaborator

    The problem is that RStudio is running renv::init() on the new project prior to loading the projects selected version of R.

    That would be the correct behavior here. That said, there shouldn't be any issues beyond the warning message printed in the console; RStudio and renv should function as expected, and the issue would go away next time renv::snapshot() is called.

  6. added theissue type on May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions