diff --git a/renv/activate.R b/renv/activate.R index ef25ef83..6487d062 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,8 +2,8 @@ local({ # the requested version of renv - version <- "1.1.7" - attr(version, "md5") <- "dd5d60f155dadff4c88c2fc6680504b4" + version <- "1.2.2" + attr(version, "md5") <- "bb69b6403b1bad0442657e9e8e57cc83" attr(version, "sha") <- NULL # the project directory @@ -226,13 +226,17 @@ local({ section <- header(sprintf("Bootstrapping renv %s", friendly)) catf(section) + # ensure the target library path exists; required for file.copy(..., recursive = TRUE) + dir.create(library, showWarnings = FALSE, recursive = TRUE) + # try to install renv from cache md5 <- attr(version, "md5", exact = TRUE) if (length(md5)) { pkgpath <- renv_bootstrap_find(version) if (length(pkgpath) && file.exists(pkgpath)) { - file.copy(pkgpath, library, recursive = TRUE) - return(invisible()) + ok <- file.copy(pkgpath, library, recursive = TRUE) + if (isTRUE(ok)) + return(invisible()) } } @@ -1231,6 +1235,21 @@ local({ } renv_bootstrap_run <- function(project, libpath, version) { + tryCatch( + renv_bootstrap_run_impl(project, libpath, version), + error = function(e) { + msg <- paste( + "failed to bootstrap renv: the project will not be loaded.", + paste("Reason:", conditionMessage(e)), + "Use `renv::activate()` to re-initialize the project.", + sep = "\n" + ) + warning(msg, call. = FALSE) + } + ) + } + + renv_bootstrap_run_impl <- function(project, libpath, version) { # perform bootstrap bootstrap(version, libpath) diff --git a/renv/profiles/lesson-requirements/renv.lock b/renv/profiles/lesson-requirements/renv.lock index a6438c5d..5d5550be 100644 --- a/renv/profiles/lesson-requirements/renv.lock +++ b/renv/profiles/lesson-requirements/renv.lock @@ -1,6 +1,6 @@ { "R": { - "Version": "4.5.2", + "Version": "4.5.3", "Repositories": [ { "Name": "carpentries", @@ -19,7 +19,7 @@ "Packages": { "renv": { "Package": "renv", - "Version": "1.1.7", + "Version": "1.2.2", "Source": "Repository", "Type": "Package", "Title": "Project Environments", @@ -70,7 +70,7 @@ "NeedsCompilation": "no", "Author": "Kevin Ushey [aut, cre] (ORCID: ), Hadley Wickham [aut] (ORCID: ), Posit Software, PBC [cph, fnd]", "Maintainer": "Kevin Ushey ", - "Repository": "CRAN" + "Repository": "https://packagemanager.posit.co/cran/__linux__/jammy/latest" } } }