From 2b1d3d2a4c44f2cc3362834ca0b7c9860411a90f Mon Sep 17 00:00:00 2001 From: Adam Smielewski Date: Wed, 4 Mar 2026 16:40:08 +0100 Subject: [PATCH] fix(): ensure lib path is created --- R/bootstrap.R | 8 ++++++-- inst/resources/activate.R | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/R/bootstrap.R b/R/bootstrap.R index fbf54d383..74685b5c6 100644 --- a/R/bootstrap.R +++ b/R/bootstrap.R @@ -66,13 +66,17 @@ bootstrap <- function(version, library) { 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()) } } diff --git a/inst/resources/activate.R b/inst/resources/activate.R index dd29ec1d7..e68eaa129 100644 --- a/inst/resources/activate.R +++ b/inst/resources/activate.R @@ -225,14 +225,18 @@ local({ friendly <- renv_bootstrap_version_friendly(version) 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()) } }