From 1ebb9147826c776fa0df3aa5d7baafb540da4071 Mon Sep 17 00:00:00 2001 From: lorenzwalthert <10477073+lorenzwalthert@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:59:39 +0000 Subject: [PATCH 1/2] Update renv dependencies --- renv.lock | 4 ++-- renv/activate.R | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/renv.lock b/renv.lock index 888247773..da9443a06 100644 --- a/renv.lock +++ b/renv.lock @@ -440,13 +440,13 @@ }, "renv": { "Package": "renv", - "Version": "1.0.5", + "Version": "1.0.7", "Source": "Repository", "Repository": "RSPM", "Requirements": [ "utils" ], - "Hash": "32c3f93e8360f667ca5863272ec8ba6a" + "Hash": "397b7b2a265bc5a7a06852524dabae20" }, "rex": { "Package": "rex", diff --git a/renv/activate.R b/renv/activate.R index 9b2e7f184..d13f9932a 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,11 +2,13 @@ local({ # the requested version of renv - version <- "1.0.5" + version <- "1.0.7" attr(version, "sha") <- NULL # the project directory - project <- getwd() + project <- Sys.getenv("RENV_PROJECT") + if (!nzchar(project)) + project <- getwd() # use start-up diagnostics if enabled diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE") @@ -129,6 +131,21 @@ local({ } + heredoc <- function(text, leave = 0) { + + # remove leading, trailing whitespace + trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text) + + # split into lines + lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]] + + # compute common indent + indent <- regexpr("[^[:space:]]", lines) + common <- min(setdiff(indent, -1L)) - leave + paste(substring(lines, common), collapse = "\n") + + } + startswith <- function(string, prefix) { substring(string, 1, nchar(prefix)) == prefix } @@ -631,6 +648,9 @@ local({ # if the user has requested an automatic prefix, generate it auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) + if (is.na(auto) && getRversion() >= "4.4.0") + auto <- "TRUE" + if (auto %in% c("TRUE", "True", "true", "1")) return(renv_bootstrap_platform_prefix_auto()) @@ -822,24 +842,23 @@ local({ # the loaded version of renv doesn't match the requested version; # give the user instructions on how to proceed - remote <- if (!is.null(description[["RemoteSha"]])) { + dev <- identical(description[["RemoteType"]], "github") + remote <- if (dev) paste("rstudio/renv", description[["RemoteSha"]], sep = "@") - } else { + else paste("renv", description[["Version"]], sep = "@") - } # display both loaded version + sha if available friendly <- renv_bootstrap_version_friendly( version = description[["Version"]], - sha = description[["RemoteSha"]] + sha = if (dev) description[["RemoteSha"]] ) - fmt <- paste( - "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", - "- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", - "- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", - sep = "\n" - ) + fmt <- heredoc(" + renv %1$s was loaded from project library, but this project is configured to use renv %2$s. + - Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile. + - Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library. + ") catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) FALSE From 47b45865591321c2697ade64f57964aa2352fd60 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sun, 15 Sep 2024 21:16:26 +0200 Subject: [PATCH 2/2] allow to break brew, since pip is a recommened way to install this from upstream. --- .github/workflows/R-CMD-check.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 924571063..e2407758f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -54,10 +54,14 @@ jobs: - name: Install system dependencies (brew) if: matrix.config.installation_method == 'brew' run: brew install pre-commit - - name: Install system dependencies (pip) - if: matrix.config.installation_method == 'pip' + - name: Install system dependencies (pip, non-macOS) + if: matrix.config.installation_method == 'pip' && matrix.config.os != 'macOS-latest' run: | pip3 install pre-commit --user + - name: Install system dependencies (pip, macOS) + if: matrix.config.installation_method == 'pip' && matrix.config.os == 'macOS-latest' + run: | + pip3 install pre-commit --user --break-system-packages - uses: r-lib/actions/setup-r-dependencies@v2 - name: Remove reticulate for other installation methods run: |