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::dependencies() ignores renv::settings$snapshot.type("explicit"), contrary to what is said in the doc. #2070

Open
ColinFay opened this issue Jan 7, 2025 · 1 comment

Comments

@ColinFay
Copy link

ColinFay commented Jan 7, 2025

Description of the bug

If I git clone the following package: https://github.com/ThinkR-open/MockShinySessionInTest

Then do

> renv::settings$snapshot.type("explicit");renv::dependencies() |> tail() |> knitr::kable()
Finding R package dependencies ... Done!


|   |Source                                               |Package    |Require |Version |Dev   |
|:--|:----------------------------------------------------|:----------|:-------|:-------|:-----|
|23 |/private/tmp/MockShinySessionInTest/R/app_config.R   |config     |        |        |FALSE |
|24 |/private/tmp/MockShinySessionInTest/README.Rmd       |rmarkdown  |        |        |FALSE |
|25 |/private/tmp/MockShinySessionInTest/README.Rmd       |knitr      |        |        |FALSE |
|26 |/private/tmp/MockShinySessionInTest/tests/spelling.R |spelling   |        |        |FALSE |
|27 |/private/tmp/MockShinySessionInTest/tests/testthat.R |testServer |        |        |FALSE |
|28 |/private/tmp/MockShinySessionInTest/tests/testthat.R |testthat   |        |        |FALSE |

You can see that the function finds the testServer package

Expected result

The doc states the following :

Explicit dependencies
Alternatively, you can suppress dependency discover and instead rely on an explicit set of packages recorded by you in a project DESCRIPTION file. Call renv::settings$snapshot.type("explicit") to enable "explicit" mode, then enumerate your dependencies in a project DESCRIPTION file.

https://rstudio.github.io/renv/reference/dependencies.html#explicit-dependencies

Given that testServer is not in the DESCRIPTION file (see here), I would have expected it to be left out of the results.

Even more, I would have expected {renv} to not look into the R, Readme.Rmd, etc...

> renv::settings$snapshot.type("explicit");renv::dependencies()$Source |> unique()
Finding R package dependencies ... Done!
 [1] "/private/tmp/MockShinySessionInTest/DESCRIPTION"     
 [2] "/private/tmp/MockShinySessionInTest/dev/01_start.R"  
 [3] "/private/tmp/MockShinySessionInTest/dev/02_dev.R"    
 [4] "/private/tmp/MockShinySessionInTest/dev/03_deploy.R" 
 [5] "/private/tmp/MockShinySessionInTest/dev/run_dev.R"   
 [6] "/private/tmp/MockShinySessionInTest/NAMESPACE"       
 [7] "/private/tmp/MockShinySessionInTest/R/app_config.R"  
 [8] "/private/tmp/MockShinySessionInTest/README.Rmd"      
 [9] "/private/tmp/MockShinySessionInTest/tests/spelling.R"
[10] "/private/tmp/MockShinySessionInTest/tests/testthat.R"

Am I missing something?

@kevinushey
Copy link
Collaborator

Sorry, the documentation here is misleading. "explicit" mode only changes how renv::snapshot() enumerates dependencies, it does not change the behavior of renv::dependencies() itself, which always infers dependencies based on static analysis of files within the project.

kevinushey added a commit that referenced this issue Jan 10, 2025
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