-
Notifications
You must be signed in to change notification settings - Fork 156
Closed
Description
I have been starting to use renv::use()
for utility scripts so they self-install dependencies, like so
#!/usr/bin/env Rscript
script_version = "0.2.0"
script_lib = tools::R_user_dir(paste0("myScript_", script_version), "data")
if (!dir.exists(script_lib)) dir.create(script_lib)
if (!requireNamespace("renv", quietly = TRUE)) {
install.packages("renv")
}
options(repos = c(rOpenSci = "https://ropensci.r-universe.dev", getOption("repos")))
renv::use(
"[email protected]",
"rnaturalearthhires",
verbose = TRUE,
sandbox = FALSE,
library = script_lib
)
library(docopt)
library(rnaturalearthhires)
sessionInfo()
The idea is that the script has a self-contained library and is portable across machines without interfering with the user library (analagous to uv tool run
). However, I note that renv::use()
always installs the packages, even if they are already in the library. This is fast when using the renv
package cache, but still adds startup overhead. Would it be possible for use()
to skip installation if the correct package version exists in the library directory already?
Metadata
Metadata
Assignees
Labels
No labels