Skip to content

Commit 1be4ef4

Browse files
authored
Merge pull request #389 from datacarpentry/update/packages
Update 13 packages
2 parents 231af26 + 487acb1 commit 1be4ef4

File tree

2 files changed

+452
-232
lines changed

2 files changed

+452
-232
lines changed

renv/activate.R

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
local({
33

44
# the requested version of renv
5-
version <- "0.16.0"
5+
version <- "0.17.0-38"
66

77
# the project directory
88
project <- getwd()
@@ -94,8 +94,11 @@ local({
9494
return(repos)
9595

9696
# 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+
}
99102

100103
# retrieve current repos
101104
repos <- getOption("repos")
@@ -344,8 +347,7 @@ local({
344347
return()
345348

346349
# allow directories
347-
info <- file.info(tarball, extra_cols = FALSE)
348-
if (identical(info$isdir, TRUE)) {
350+
if (dir.exists(tarball)) {
349351
name <- sprintf("renv_%s.tar.gz", version)
350352
tarball <- file.path(tarball, name)
351353
}
@@ -659,8 +661,8 @@ local({
659661
if (version == loadedversion)
660662
return(TRUE)
661663

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
664666
components <- strsplit(loadedversion, "[.-]")[[1]]
665667
remote <- if (length(components) == 4L)
666668
paste("rstudio/renv", loadedversion, sep = "@")
@@ -700,6 +702,12 @@ local({
700702
# warn if the version of renv loaded does not match
701703
renv_bootstrap_validate_version(version)
702704

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+
703711
# load the project
704712
renv::load(project)
705713

@@ -842,11 +850,29 @@ local({
842850

843851
renv_json_read <- function(file = NULL, text = NULL) {
844852

853+
jlerr <- NULL
854+
845855
# 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)
848874
else
849-
renv_json_read_default(file, text)
875+
stop(json)
850876

851877
}
852878

0 commit comments

Comments
 (0)