Skip to content

Commit 6ca98fa

Browse files
authored
Merge pull request #435 from datacarpentry/update/packages
Update 17 packages
2 parents a6ca574 + 849e3a3 commit 6ca98fa

File tree

2 files changed

+92
-85
lines changed

2 files changed

+92
-85
lines changed

renv/activate.R

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
local({
33

44
# the requested version of renv
5-
version <- "1.0.5"
5+
version <- "1.0.7"
66
attr(version, "sha") <- NULL
77

88
# the project directory
9-
project <- getwd()
9+
project <- Sys.getenv("RENV_PROJECT")
10+
if (!nzchar(project))
11+
project <- getwd()
1012

1113
# use start-up diagnostics if enabled
1214
diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE")
@@ -129,6 +131,21 @@ local({
129131

130132
}
131133

134+
heredoc <- function(text, leave = 0) {
135+
136+
# remove leading, trailing whitespace
137+
trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text)
138+
139+
# split into lines
140+
lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]]
141+
142+
# compute common indent
143+
indent <- regexpr("[^[:space:]]", lines)
144+
common <- min(setdiff(indent, -1L)) - leave
145+
paste(substring(lines, common), collapse = "\n")
146+
147+
}
148+
132149
startswith <- function(string, prefix) {
133150
substring(string, 1, nchar(prefix)) == prefix
134151
}
@@ -631,6 +648,9 @@ local({
631648

632649
# if the user has requested an automatic prefix, generate it
633650
auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA)
651+
if (is.na(auto) && getRversion() >= "4.4.0")
652+
auto <- "TRUE"
653+
634654
if (auto %in% c("TRUE", "True", "true", "1"))
635655
return(renv_bootstrap_platform_prefix_auto())
636656

@@ -822,24 +842,23 @@ local({
822842

823843
# the loaded version of renv doesn't match the requested version;
824844
# give the user instructions on how to proceed
825-
remote <- if (!is.null(description[["RemoteSha"]])) {
845+
dev <- identical(description[["RemoteType"]], "github")
846+
remote <- if (dev)
826847
paste("rstudio/renv", description[["RemoteSha"]], sep = "@")
827-
} else {
848+
else
828849
paste("renv", description[["Version"]], sep = "@")
829-
}
830850

831851
# display both loaded version + sha if available
832852
friendly <- renv_bootstrap_version_friendly(
833853
version = description[["Version"]],
834-
sha = description[["RemoteSha"]]
854+
sha = if (dev) description[["RemoteSha"]]
835855
)
836856

837-
fmt <- paste(
838-
"renv %1$s was loaded from project library, but this project is configured to use renv %2$s.",
839-
"- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.",
840-
"- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.",
841-
sep = "\n"
842-
)
857+
fmt <- heredoc("
858+
renv %1$s was loaded from project library, but this project is configured to use renv %2$s.
859+
- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.
860+
- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.
861+
")
843862
catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote)
844863

845864
FALSE

0 commit comments

Comments
 (0)