Closed krumsiek closed 3 years ago
Can you share your project sources?
Hi Kevin.
This is now difficult to reproduce for me, since I've been meddling around with renv in the project. (removed it etc.)
The same happens when I do this:
renv::snapshot()
(file looks good)renv::activate()
(it says file out of sync, despite the fact that I didn't change anything)renv::snaphot()
again (empty file)I seems that the activation process in this cases makes renv "forget" which packages it parsed for the project?
Not sure if this version is intended behavior though. The original report was odd since it was a project with renv already activated, I just did the upgrade.
Another version of the issue that I think can be reproduced:
renv::activate()
renv::snapshot()
It asks to create a library that is way too short (it should be dozens of packages).
> renv::activate()
* Project '~/work/git/renv_testing' loaded. [renv 0.12.3-67]
> renv::snapshot()
The following package(s) will be updated in the lockfile:
# CRAN ===============================
- MASS [* -> 7.3-51.6]
- Matrix [* -> 1.2-18]
- cluster [* -> 2.1.0]
- foreign [* -> 0.8-76]
- lattice [* -> 0.20-41]
- mgcv [* -> 1.8-31]
- nlme [* -> 3.1-148]
- nnet [* -> 7.3-14]
- rpart [* -> 4.1-15]
- survival [* -> 3.2-3]
renv::snapshot()
will ultimately just capture whatever happens to be in your project library; I wonder if the library path was unexpectedly changed, or those packages were removed?
I believe you could "repair" this state by calling:
renv::install()
renv::snapshot()
Yes, I think this might be a misunderstanding of the renv
functionality on my end. renv::init()
seems to be the one that parses all dependencies from my code files.
My confusion was that I thought renv
does all dependency parsing automatically at all times. For example, I now added a new library, but only as a library
call in my code file, without doing anything else. renv::snapshot
will not see that, as you said. renv::init
and then discard and reinitialize added that package to the lockfile.
I never explicitly worked with the Project Library in RStudio.
If you haven't seen it already, https://rstudio.github.io/renv/articles/renv.html should be a good introduction. renv::snapshot()
basically just saves the state of your library to the lockfile renv.lock
; renv::restore()
is the reverse operation.
I did see it, but apparently didn't fully get it. Thanks for the clarification and the great package.
No worries; thanks for the question! I hope you find the package useful.
I just upgraded to the new 0.12.3-67 using renv::upgrade() in my project. I then ran renv::snapshot() again since renv said my lock file is out of sync. However, after that operation, renv.lock is basically empty, with just renv itself in there. See below also the log from the snapshot command: