|
2 | 2 | local({
|
3 | 3 |
|
4 | 4 | # the requested version of renv
|
5 |
| - version <- "0.16.0" |
| 5 | + version <- "0.17.0-38" |
6 | 6 |
|
7 | 7 | # the project directory
|
8 | 8 | project <- getwd()
|
@@ -94,8 +94,11 @@ local({
|
94 | 94 | return(repos)
|
95 | 95 |
|
96 | 96 | # if we're testing, re-use the test repositories
|
97 |
| - if (renv_bootstrap_tests_running()) |
98 |
| - return(getOption("renv.tests.repos")) |
| 97 | + if (renv_bootstrap_tests_running()) { |
| 98 | + repos <- getOption("renv.tests.repos") |
| 99 | + if (!is.null(repos)) |
| 100 | + return(repos) |
| 101 | + } |
99 | 102 |
|
100 | 103 | # retrieve current repos
|
101 | 104 | repos <- getOption("repos")
|
@@ -344,8 +347,7 @@ local({
|
344 | 347 | return()
|
345 | 348 |
|
346 | 349 | # allow directories
|
347 |
| - info <- file.info(tarball, extra_cols = FALSE) |
348 |
| - if (identical(info$isdir, TRUE)) { |
| 350 | + if (dir.exists(tarball)) { |
349 | 351 | name <- sprintf("renv_%s.tar.gz", version)
|
350 | 352 | tarball <- file.path(tarball, name)
|
351 | 353 | }
|
@@ -659,8 +661,8 @@ local({
|
659 | 661 | if (version == loadedversion)
|
660 | 662 | return(TRUE)
|
661 | 663 |
|
662 |
| - # assume four-component versions are from GitHub; three-component |
663 |
| - # versions are from CRAN |
| 664 | + # assume four-component versions are from GitHub; |
| 665 | + # three-component versions are from CRAN |
664 | 666 | components <- strsplit(loadedversion, "[.-]")[[1]]
|
665 | 667 | remote <- if (length(components) == 4L)
|
666 | 668 | paste("rstudio/renv", loadedversion, sep = "@")
|
@@ -700,6 +702,12 @@ local({
|
700 | 702 | # warn if the version of renv loaded does not match
|
701 | 703 | renv_bootstrap_validate_version(version)
|
702 | 704 |
|
| 705 | + # execute renv load hooks, if any |
| 706 | + hooks <- getHook("renv::autoload") |
| 707 | + for (hook in hooks) |
| 708 | + if (is.function(hook)) |
| 709 | + tryCatch(hook(), error = warning) |
| 710 | + |
703 | 711 | # load the project
|
704 | 712 | renv::load(project)
|
705 | 713 |
|
@@ -842,11 +850,29 @@ local({
|
842 | 850 |
|
843 | 851 | renv_json_read <- function(file = NULL, text = NULL) {
|
844 | 852 |
|
| 853 | + jlerr <- NULL |
| 854 | + |
845 | 855 | # if jsonlite is loaded, use that instead
|
846 |
| - if ("jsonlite" %in% loadedNamespaces()) |
847 |
| - renv_json_read_jsonlite(file, text) |
| 856 | + if ("jsonlite" %in% loadedNamespaces()) { |
| 857 | + |
| 858 | + json <- catch(renv_json_read_jsonlite(file, text)) |
| 859 | + if (!inherits(json, "error")) |
| 860 | + return(json) |
| 861 | + |
| 862 | + jlerr <- json |
| 863 | + |
| 864 | + } |
| 865 | + |
| 866 | + # otherwise, fall back to the default JSON reader |
| 867 | + json <- catch(renv_json_read_default(file, text)) |
| 868 | + if (!inherits(json, "error")) |
| 869 | + return(json) |
| 870 | + |
| 871 | + # report an error |
| 872 | + if (!is.null(jlerr)) |
| 873 | + stop(jlerr) |
848 | 874 | else
|
849 |
| - renv_json_read_default(file, text) |
| 875 | + stop(json) |
850 | 876 |
|
851 | 877 | }
|
852 | 878 |
|
|
0 commit comments