Skip to content

Commit 6c91a6c

Browse files
chore: bump renv version
1 parent 713a2b0 commit 6c91a6c

2 files changed

Lines changed: 116 additions & 59 deletions

File tree

renv.lock

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,57 +1277,10 @@
12771277
},
12781278
"renv": {
12791279
"Package": "renv",
1280-
"Version": "1.1.5",
1281-
"Source": "Repository",
1282-
"Type": "Package",
1283-
"Title": "Project Environments",
1284-
"Authors@R": "c( person(\"Kevin\", \"Ushey\", role = c(\"aut\", \"cre\"), email = \"kevin@rstudio.com\", comment = c(ORCID = \"0000-0003-2880-7407\")), person(\"Hadley\", \"Wickham\", role = c(\"aut\"), email = \"hadley@rstudio.com\", comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )",
1285-
"Description": "A dependency management toolkit for R. Using 'renv', you can create and manage project-local R libraries, save the state of these libraries to a 'lockfile', and later restore your library as required. Together, these tools can help make your projects more isolated, portable, and reproducible.",
1286-
"License": "MIT + file LICENSE",
1287-
"URL": "https://rstudio.github.io/renv/, https://github.com/rstudio/renv",
1288-
"BugReports": "https://github.com/rstudio/renv/issues",
1289-
"Imports": [
1290-
"utils"
1291-
],
1292-
"Suggests": [
1293-
"BiocManager",
1294-
"cli",
1295-
"compiler",
1296-
"covr",
1297-
"cpp11",
1298-
"devtools",
1299-
"generics",
1300-
"gitcreds",
1301-
"jsonlite",
1302-
"jsonvalidate",
1303-
"knitr",
1304-
"miniUI",
1305-
"modules",
1306-
"packrat",
1307-
"pak",
1308-
"R6",
1309-
"remotes",
1310-
"reticulate",
1311-
"rmarkdown",
1312-
"rstudioapi",
1313-
"shiny",
1314-
"testthat",
1315-
"uuid",
1316-
"waldo",
1317-
"yaml",
1318-
"webfakes"
1319-
],
1320-
"Encoding": "UTF-8",
1321-
"RoxygenNote": "7.3.2",
1322-
"VignetteBuilder": "knitr",
1323-
"Config/Needs/website": "tidyverse/tidytemplate",
1324-
"Config/testthat/edition": "3",
1325-
"Config/testthat/parallel": "true",
1326-
"Config/testthat/start-first": "bioconductor,python,install,restore,snapshot,retrieve,remotes",
1327-
"NeedsCompilation": "no",
1328-
"Author": "Kevin Ushey [aut, cre] (ORCID: <https://orcid.org/0000-0003-2880-7407>), Hadley Wickham [aut] (ORCID: <https://orcid.org/0000-0003-4757-117X>), Posit Software, PBC [cph, fnd]",
1329-
"Maintainer": "Kevin Ushey <kevin@rstudio.com>",
1330-
"Repository": "RSPM"
1280+
"Version": "1.2.2",
1281+
"OS_type": null,
1282+
"Repository": "RSPM",
1283+
"Source": "Repository"
13311284
},
13321285
"rex": {
13331286
"Package": "rex",

renv/activate.R

Lines changed: 112 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
local({
33

44
# the requested version of renv
5-
version <- "1.1.5"
5+
version <- "1.2.2"
6+
attr(version, "md5") <- "02a5732a42a5a912a107dfdc37f7c20d"
67
attr(version, "sha") <- NULL
78

89
# the project directory
@@ -168,6 +169,16 @@ local({
168169
if (quiet)
169170
return(invisible())
170171

172+
# also check for config environment variables that should suppress messages
173+
# https://github.com/rstudio/renv/issues/2214
174+
enabled <- Sys.getenv("RENV_CONFIG_STARTUP_QUIET", unset = NA)
175+
if (!is.na(enabled) && tolower(enabled) %in% c("true", "1"))
176+
return(invisible())
177+
178+
enabled <- Sys.getenv("RENV_CONFIG_SYNCHRONIZED_CHECK", unset = NA)
179+
if (!is.na(enabled) && tolower(enabled) %in% c("false", "0"))
180+
return(invisible())
181+
171182
msg <- sprintf(fmt, ...)
172183
cat(msg, file = stdout(), sep = if (appendLF) "\n" else "")
173184

@@ -215,6 +226,20 @@ local({
215226
section <- header(sprintf("Bootstrapping renv %s", friendly))
216227
catf(section)
217228

229+
# ensure the target library path exists; required for file.copy(..., recursive = TRUE)
230+
dir.create(library, showWarnings = FALSE, recursive = TRUE)
231+
232+
# try to install renv from cache
233+
md5 <- attr(version, "md5", exact = TRUE)
234+
if (length(md5)) {
235+
pkgpath <- renv_bootstrap_find(version)
236+
if (length(pkgpath) && file.exists(pkgpath)) {
237+
ok <- file.copy(pkgpath, library, recursive = TRUE)
238+
if (isTRUE(ok))
239+
return(invisible())
240+
}
241+
}
242+
218243
# attempt to download renv
219244
catf("- Downloading renv ... ", appendLF = FALSE)
220245
withCallingHandlers(
@@ -240,7 +265,6 @@ local({
240265

241266
# add empty line to break up bootstrapping from normal output
242267
catf("")
243-
244268
return(invisible())
245269
}
246270

@@ -257,12 +281,20 @@ local({
257281
repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA)
258282
if (!is.na(repos)) {
259283

260-
# check for RSPM; if set, use a fallback repository for renv
261-
rspm <- Sys.getenv("RSPM", unset = NA)
262-
if (identical(rspm, repos))
263-
repos <- c(RSPM = rspm, CRAN = cran)
284+
# split on ';' if present
285+
parts <- strsplit(repos, ";", fixed = TRUE)[[1L]]
264286

265-
return(repos)
287+
# split into named repositories if present
288+
idx <- regexpr("=", parts, fixed = TRUE)
289+
keys <- substring(parts, 1L, idx - 1L)
290+
vals <- substring(parts, idx + 1L)
291+
names(vals) <- keys
292+
293+
# if we have a single unnamed repository, call it CRAN
294+
if (length(vals) == 1L && identical(keys, ""))
295+
names(vals) <- "CRAN"
296+
297+
return(vals)
266298

267299
}
268300

@@ -511,6 +543,51 @@ local({
511543

512544
}
513545

546+
renv_bootstrap_find <- function(version) {
547+
548+
path <- renv_bootstrap_find_cache(version)
549+
if (length(path) && file.exists(path)) {
550+
catf("- Using renv %s from global package cache", version)
551+
return(path)
552+
}
553+
554+
}
555+
556+
renv_bootstrap_find_cache <- function(version) {
557+
558+
md5 <- attr(version, "md5", exact = TRUE)
559+
if (is.null(md5))
560+
return()
561+
562+
# infer path to renv cache
563+
cache <- Sys.getenv("RENV_PATHS_CACHE", unset = "")
564+
if (!nzchar(cache)) {
565+
root <- Sys.getenv("RENV_PATHS_ROOT", unset = NA)
566+
if (!is.na(root))
567+
cache <- file.path(root, "cache")
568+
}
569+
570+
if (!nzchar(cache)) {
571+
tools <- asNamespace("tools")
572+
if (is.function(tools$R_user_dir)) {
573+
root <- tools$R_user_dir("renv", "cache")
574+
cache <- file.path(root, "cache")
575+
}
576+
}
577+
578+
# start completing path to cache
579+
file.path(
580+
cache,
581+
renv_bootstrap_cache_version(),
582+
renv_bootstrap_platform_prefix(),
583+
"renv",
584+
version,
585+
md5,
586+
"renv"
587+
)
588+
589+
}
590+
514591
renv_bootstrap_download_tarball <- function(version) {
515592

516593
# if the user has provided the path to a tarball via
@@ -979,7 +1056,7 @@ local({
9791056

9801057
renv_bootstrap_validate_version_release <- function(version, description) {
9811058
expected <- description[["Version"]]
982-
is.character(expected) && identical(expected, version)
1059+
is.character(expected) && identical(c(expected), c(version))
9831060
}
9841061

9851062
renv_bootstrap_hash_text <- function(text) {
@@ -1158,6 +1235,21 @@ local({
11581235
}
11591236

11601237
renv_bootstrap_run <- function(project, libpath, version) {
1238+
tryCatch(
1239+
renv_bootstrap_run_impl(project, libpath, version),
1240+
error = function(e) {
1241+
msg <- paste(
1242+
"failed to bootstrap renv: the project will not be loaded.",
1243+
paste("Reason:", conditionMessage(e)),
1244+
"Use `renv::activate()` to re-initialize the project.",
1245+
sep = "\n"
1246+
)
1247+
warning(msg, call. = FALSE)
1248+
}
1249+
)
1250+
}
1251+
1252+
renv_bootstrap_run_impl <- function(project, libpath, version) {
11611253

11621254
# perform bootstrap
11631255
bootstrap(version, libpath)
@@ -1181,6 +1273,18 @@ local({
11811273

11821274
}
11831275

1276+
renv_bootstrap_cache_version <- function() {
1277+
# NOTE: users should normally not override the cache version;
1278+
# this is provided just to make testing easier
1279+
Sys.getenv("RENV_CACHE_VERSION", unset = "v5")
1280+
}
1281+
1282+
renv_bootstrap_cache_version_previous <- function() {
1283+
version <- renv_bootstrap_cache_version()
1284+
number <- as.integer(substring(version, 2L))
1285+
paste("v", number - 1L, sep = "")
1286+
}
1287+
11841288
renv_json_read <- function(file = NULL, text = NULL) {
11851289

11861290
jlerr <- NULL

0 commit comments

Comments
 (0)