Skip to content

Commit

Permalink
[actions] update 63 packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyhodges authored May 2, 2023
1 parent cd0d32c commit 9fbd7ca
Show file tree
Hide file tree
Showing 3 changed files with 711 additions and 360 deletions.
68 changes: 53 additions & 15 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.3"

# the project directory
project <- getwd()
Expand Down Expand Up @@ -63,6 +63,10 @@ local({
if (is.environment(x) || length(x)) x else y
}

`%??%` <- function(x, y) {
if (is.null(x)) y else x
}

bootstrap <- function(version, library) {

# attempt to download renv
Expand All @@ -83,28 +87,39 @@ local({

renv_bootstrap_repos <- function() {

# get CRAN repository
cran <- getOption("renv.repos.cran", "https://cloud.r-project.org")

# check for repos override
repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA)
if (!is.na(repos))
if (!is.na(repos)) {

# check for RSPM; if set, use a fallback repository for renv
rspm <- Sys.getenv("RSPM", unset = NA)
if (identical(rspm, repos))
repos <- c(RSPM = rspm, CRAN = cran)

return(repos)

}

# check for lockfile repositories
repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity)
if (!inherits(repos, "error") && length(repos))
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")

# ensure @CRAN@ entries are resolved
repos[repos == "@CRAN@"] <- getOption(
"renv.repos.cran",
"https://cloud.r-project.org"
)
repos[repos == "@CRAN@"] <- cran

# add in renv.bootstrap.repos if set
default <- c(FALLBACK = "https://cloud.r-project.org")
Expand Down Expand Up @@ -344,8 +359,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 +673,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 +714,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 +862,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

0 comments on commit 9fbd7ca

Please sign in to comment.