Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local({

# the requested version of renv
version <- "0.16.0"
version <- "0.17.2"

# the project directory
project <- getwd()
Expand Down Expand Up @@ -94,8 +94,11 @@ local({
return(repos)

# if we're testing, re-use the test repositories
if (renv_bootstrap_tests_running())
return(getOption("renv.tests.repos"))
if (renv_bootstrap_tests_running()) {
repos <- getOption("renv.tests.repos")
if (!is.null(repos))
return(repos)
}

# retrieve current repos
repos <- getOption("repos")
Expand Down Expand Up @@ -344,8 +347,7 @@ local({
return()

# allow directories
info <- file.info(tarball, extra_cols = FALSE)
if (identical(info$isdir, TRUE)) {
if (dir.exists(tarball)) {
name <- sprintf("renv_%s.tar.gz", version)
tarball <- file.path(tarball, name)
}
Expand Down Expand Up @@ -659,8 +661,8 @@ local({
if (version == loadedversion)
return(TRUE)

# assume four-component versions are from GitHub; three-component
# versions are from CRAN
# assume four-component versions are from GitHub;
# three-component versions are from CRAN
components <- strsplit(loadedversion, "[.-]")[[1]]
remote <- if (length(components) == 4L)
paste("rstudio/renv", loadedversion, sep = "@")
Expand Down Expand Up @@ -700,6 +702,12 @@ local({
# warn if the version of renv loaded does not match
renv_bootstrap_validate_version(version)

# execute renv load hooks, if any
hooks <- getHook("renv::autoload")
for (hook in hooks)
if (is.function(hook))
tryCatch(hook(), error = warning)

# load the project
renv::load(project)

Expand Down Expand Up @@ -842,11 +850,29 @@ local({

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

jlerr <- NULL

# if jsonlite is loaded, use that instead
if ("jsonlite" %in% loadedNamespaces())
renv_json_read_jsonlite(file, text)
if ("jsonlite" %in% loadedNamespaces()) {

json <- catch(renv_json_read_jsonlite(file, text))
if (!inherits(json, "error"))
return(json)

jlerr <- json

}

# otherwise, fall back to the default JSON reader
json <- catch(renv_json_read_default(file, text))
if (!inherits(json, "error"))
return(json)

# report an error
if (!is.null(jlerr))
stop(jlerr)
else
renv_json_read_default(file, text)
stop(json)

}

Expand Down
Loading