Open johnForne opened 7 months ago
The lockfile captures both the top-level package dependencies, as well as those package's recursive dependencies. Could that explain why? For example, the tidyverse
package has a large number of recursive dependencies:
> tools::package_dependencies("tidyverse", recursive = TRUE)[[1]]
[1] "broom" "conflicted" "cli" "dbplyr"
[5] "dplyr" "dtplyr" "forcats" "ggplot2"
[9] "googledrive" "googlesheets4" "haven" "hms"
[13] "httr" "jsonlite" "lubridate" "magrittr"
[17] "modelr" "pillar" "purrr" "ragg"
[21] "readr" "readxl" "reprex" "rlang"
[25] "rstudioapi" "rvest" "stringr" "tibble"
[29] "tidyr" "xml2" "backports" "ellipsis"
[33] "generics" "glue" "lifecycle" "utils"
[37] "memoise" "blob" "DBI" "methods"
[41] "R6" "tidyselect" "vctrs" "withr"
[45] "data.table" "grDevices" "grid" "gtable"
[49] "isoband" "MASS" "mgcv" "scales"
[53] "stats" "gargle" "uuid" "cellranger"
[57] "curl" "ids" "rematch2" "cpp11"
[61] "pkgconfig" "mime" "openssl" "timechange"
[65] "fansi" "utf8" "systemfonts" "textshaping"
[69] "clipr" "crayon" "vroom" "tzdb"
[73] "progress" "callr" "fs" "knitr"
[77] "rmarkdown" "selectr" "stringi" "processx"
[81] "rematch" "rappdirs" "evaluate" "highr"
[85] "tools" "xfun" "yaml" "graphics"
[89] "cachem" "nlme" "Matrix" "splines"
[93] "askpass" "prettyunits" "bslib" "fontawesome"
[97] "htmltools" "jquerylib" "tinytex" "farver"
[101] "labeling" "munsell" "RColorBrewer" "viridisLite"
[105] "bit64" "sys" "bit" "base64enc"
[109] "sass" "fastmap" "digest" "lattice"
[113] "colorspace" "ps"
Thanks Kevin - much appreciated. That's good to know. I wonder if it is possible/makes sense to have an optional argument to limit the lock file to include (direct) dependences only? Like what 'dependencies()' returns?
But that would give you an incomplete lockfile -- if you tried to call renv::restore()
, we wouldn't know what versions of those package's dependencies you need, and so you'd risk issues due to a change in the R library state.
I wonder if it is possible/makes sense to have an optional argument to limit the lock file to include (direct) dependences only? Like what 'dependencies()' returns?
I think this would be useful from my purposes. I find the inclusion of recursive dependencies to be distracting and sometimes leads to dependency conflicts.
But that would give you an incomplete lockfile -- if you tried to call
renv::restore()
, we wouldn't know what versions of those package's dependencies you need, and so you'd risk issues due to a change in the R library state.
Is there a way to just rely on the underlying package dependency specifications to identify these versions? Coming from Python, you can just add the main packages you need installed to the requirements.txt (or environment.yml if using conda), and pip will automatically install the dependencies of those packages as needed.
For example, if I have a project that requires pandas 2.2.1, pip/conda will also install numpy 1.26.4 as a dependency (based on pandas specifying numpy<2 in its environment.yml) without needing to pin that version of numpy to the dependency specs.
I'd find it easier to just manage these direct dependencies, but having less familiarity with R than Python's ecosystem, I might be missing the mark here.
Kia ora
I am new to renv:: and think this sounds like it could be really useful for helping make our code more reproducible.
However, I've run into an issue that I don't know whether it is me or the code...
The situation is that I have an existing project that I've run 'renv::init()' within and I then checked the lockfile to see what packages it listed. The issue is that it seems to list every package that I've ever used in R - rather than only the packages within the project.
renv reference material suggests that
I tested this by calling 'renv::dependences()' and found that it listed the 43 packages I expected with my project. In contrast, 'renv::lockfile_read()' lists 254 packages!
Interestingly, I then tested what happened if I set up a brand new project with only one 'test.R' file in it with the following code...
This time I found that 'd' had the two packages (renv:: + tidyverse::) that I expected. However, the lockfile seemed to contain all sorts of packages (108) that were more than the 31 packages in tidyverse + the 1 renv package.
Can you please let me know how to actually "Capture only packages which appear to be used in your project"?
Thanks in advance,
John