Skip to content
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

renv start with a new package won't react to the library() function to load package #1855

Open
yuanqingye opened this issue Mar 15, 2024 · 6 comments

Comments

@yuanqingye
Copy link

Hi

Start a new package(not a project)

create an r file, with following line:

library(tictoc)

renv::status() didn't reflect the status change,it saids nothing changed, but a package tictoc is used but not installed and not recorded. There should be an inconsistency.

Is this on purpose design? or a bug? or I make a wrong operation?

@kevinushey
Copy link
Collaborator

Did you choose to use "explicit" snapshots for the package? If so, then renv will only infer dependencies from the DESCRIPTION file. Please see https://rstudio.github.io/renv/articles/faq.html for more details.

@yuanqingye
Copy link
Author

yuanqingye commented Mar 18, 2024

Did you choose to use "explicit" snapshots for the package? If so, then renv will only infer dependencies from the DESCRIPTION file. Please see https://rstudio.github.io/renv/articles/faq.html for more details.

Thank you for reply
What did you mean by "use explicit" snapshot for package?
When I create a new package, there are only two choice, one for if use renv to manage the package, and the other is regarding git, I didn't see any choice to use "explicit" snapshot or not.
Did you mean, in the "package mode" renv will not update automatically when the r-file use any package,
It will know it only you record it in the DESCRIPTION file?
Or you manually can inform renv by
1install it by renv::intall('package_name')
2run renv::snapshot()
to tell renv to update some packages.

@yuanqingye
Copy link
Author

Did you choose to use "explicit" snapshots for the package? If so, then renv will only infer dependencies from the DESCRIPTION file. Please see https://rstudio.github.io/renv/articles/faq.html for more details.

Hi I think I got what you mean here, there is snapshot type setting
And in Project, by default it is 'implicit', it will get the info from renv::dependencies
while in Package, by default it is 'explicit', it will get the info from DESCRIPTION file only.

By the way, I noticed there is some libraries installed in the renv::paths$sandbox().
Do you know where those libraries come from? I think all project managed by renv will treat the package inside that folder as being already installed.

@yuanqingye
Copy link
Author

Hi I think I also figure out what should be in sandbox by default.
It is installed.packages(priority = c('base','recommended'))
Never mind.

Thank you for tell me some clue to find these infos

@kevinushey
Copy link
Collaborator

Right, exactly -- the sandbox is described in https://rstudio.github.io/renv/reference/sandbox.html. The intention here is that users might install packages into the default library paths, and we want to avoid those packages being made available by default in renv projects (to help ensure they are properly encapsulated).

@yuanqingye
Copy link
Author

yuanqingye commented Mar 19, 2024

Right, exactly -- the sandbox is described in https://rstudio.github.io/renv/reference/sandbox.html. The intention here is that users might install packages into the default library paths, and we want to avoid those packages being made available by default in renv projects (to help ensure they are properly encapsulated).

In order to confirm I understand your meaning, I try to clarify:
To isolate project's package using, there are two ways:
1 Don't access any package in default library, every project will reinstall all 'base' and 'recommended' package.
2 We only access the 'base' and 'recommneded' package in default library, keep away from other packages.

So you choose the 2nd way, and this way you don't need to install 'base' and 'recommended' package everytime you start a new project, and those packages need to get update only when R's version has changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants