New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dcoumentation: mention renv::hydrate() as main step in the worklow? #588
Comments
I realize things are more complicated: |
It depends on what you really want:
If you do indeed want to re-use whatever happens to be available in your user library,
That is correct -- note that this is mainly modeled after the main way users work with R outside of
Can you elaborate? If your project is using a package, but it is not installed in the project library, then Ultimately though I view |
Thanks Kevin for the prompt answer! I think the whole issue is about It's tricky to do a reprex (reprex fails when using
|
That seems unintentional to me: I'll try to figure out what's going on. Thanks for reporting! |
Hi Kevin! Do you have a milestone for this issue? Not being able to rely on For now I use the code below as workaround, to you have an better/alternate to suggest? Thanks a lot!!
|
To make sure I understand the issue, the problem here is that:
That is, |
The state is a bit weird because "technically" the lockfile and library are actually in sync; it's just that the project references from packages which haven't yet been installed. |
Exactly! The issue comes with packages that were added in scripts after the first This suggests that Thanks!! |
Thanks! Implemented on master now with 7bd669b. |
Thanks, this is great! So this means now the workflow is that every "newly required" package (i.e. after init) should be 1) used with a Is that correct? If yes, I would strongly recommend updating the documentation, as there is now an important difference with the traditional workflow (install a package once, which will last forever for any script) and the renv one (renv::install a package every time that you use it in a renv project, unless you were already calling it when you did the This leads to a new request/question: is there a function that automatically screens and installs all "referenced but not installed packages"? That would be very useful, to make the workflow less manual! Thanks!!! |
Yes, that's correct and expected. (The project library is isolated from the default user library, so packages in that library aren't automatically visible in projects.)
This is documented in https://rstudio.github.io/renv/articles/renv.html, in that we instruct users to install packages as required in the project.
That's what |
Thanks Kevin! This takes us back to the initial point about the documentation: in my view, the sentence Work in the project as normal, installing and removing new R packages as they are needed in the project is quite misleading. There are two distinct workflows:
This is very different! I installed dplyr four years ago, and in a normal workflow never re-installed it. Now renv's workflow calls for installing manually it in every project (unless present at init time). This is a fundamental difference that would be worth clarifying in the documentation! Now about Thanks a lot! |
I feel the use of
renv::hydrate()
is not documented enough in the renv documentation? As a newcomer, I had to dig a lot to understand it is a fundamental function that I am likely to use very often!The documentation seems to be based on a workflow where any time a user would need a new library (new to the project, not to the system), she would manually install it with
install.packages()
. But this is rather a rare case, most of the time one is just usinglibrary()
in a script to load a new package (again, new here refers to new to the project). In that case,renv::status()
will not detect anything, and then the user won't be able to load that package! After a lot of trial-and-error, I believe the right function isrenv::hydrate()
in that case. As a newcomer, I tried firstrestore
,refresh
,clean
,record
.Is it correct that after adding a new
library()
call the right function isrenv::hydrate()
? If yes, this would be worth adding in the main workflow.I suggest adding in the Workflow section of https://rstudio.github.io/renv/articles/renv.html:
library(pkg)
in your script and thenrenv::hydrate()
The text was updated successfully, but these errors were encountered: