diff --git a/NEWS.md b/NEWS.md index 6f17283d9..af793a291 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ + # renv (development version) +* Fixed an issue where `renv`'s activate script failed to report version + conflict errors when starting up. (#1874) + + # renv 1.0.6 * Fixed an issue where downloads could fail with curl >= 8.7.1. (#1869) diff --git a/R/bootstrap.R b/R/bootstrap.R index f6e087545..b66e4c725 100644 --- a/R/bootstrap.R +++ b/R/bootstrap.R @@ -32,6 +32,21 @@ header <- function(label, } +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 } diff --git a/R/utils.R b/R/utils.R index 47149738f..a3874f078 100644 --- a/R/utils.R +++ b/R/utils.R @@ -381,21 +381,6 @@ nth <- function(x, i) { x[[i]] } -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") - -} - find <- function(x, f, ...) { for (i in seq_along(x)) if (!is.null(value <- f(x[[i]], ...))) diff --git a/inst/resources/activate.R b/inst/resources/activate.R index 12e6fa471..309266dda 100644 --- a/inst/resources/activate.R +++ b/inst/resources/activate.R @@ -131,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 }