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
Opening a new project with renv selected causes an incorrect lock file to be generated #14526
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
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.
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
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".
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.
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.
Activity
samcofer commentedon Apr 9, 2024
@kevinushey
kevinushey commentedon Apr 22, 2024
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.