|
2 | 2 | local({
|
3 | 3 |
|
4 | 4 | # the requested version of renv
|
5 |
| - version <- "1.0.5" |
| 5 | + version <- "1.0.7" |
6 | 6 | attr(version, "sha") <- NULL
|
7 | 7 |
|
8 | 8 | # the project directory
|
9 |
| - project <- getwd() |
| 9 | + project <- Sys.getenv("RENV_PROJECT") |
| 10 | + if (!nzchar(project)) |
| 11 | + project <- getwd() |
10 | 12 |
|
11 | 13 | # use start-up diagnostics if enabled
|
12 | 14 | diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE")
|
@@ -129,6 +131,21 @@ local({
|
129 | 131 |
|
130 | 132 | }
|
131 | 133 |
|
| 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 | + |
132 | 149 | startswith <- function(string, prefix) {
|
133 | 150 | substring(string, 1, nchar(prefix)) == prefix
|
134 | 151 | }
|
@@ -631,6 +648,9 @@ local({
|
631 | 648 |
|
632 | 649 | # if the user has requested an automatic prefix, generate it
|
633 | 650 | auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA)
|
| 651 | + if (is.na(auto) && getRversion() >= "4.4.0") |
| 652 | + auto <- "TRUE" |
| 653 | + |
634 | 654 | if (auto %in% c("TRUE", "True", "true", "1"))
|
635 | 655 | return(renv_bootstrap_platform_prefix_auto())
|
636 | 656 |
|
@@ -822,24 +842,23 @@ local({
|
822 | 842 |
|
823 | 843 | # the loaded version of renv doesn't match the requested version;
|
824 | 844 | # 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) |
826 | 847 | paste("rstudio/renv", description[["RemoteSha"]], sep = "@")
|
827 |
| - } else { |
| 848 | + else |
828 | 849 | paste("renv", description[["Version"]], sep = "@")
|
829 |
| - } |
830 | 850 |
|
831 | 851 | # display both loaded version + sha if available
|
832 | 852 | friendly <- renv_bootstrap_version_friendly(
|
833 | 853 | version = description[["Version"]],
|
834 |
| - sha = description[["RemoteSha"]] |
| 854 | + sha = if (dev) description[["RemoteSha"]] |
835 | 855 | )
|
836 | 856 |
|
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 | + ") |
843 | 862 | catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote)
|
844 | 863 |
|
845 | 864 | FALSE
|
|
0 commit comments