Skip to content

Commit

Permalink
don't require RemoteRef field for r-universe record (#2068)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Jan 6, 2025
1 parent 039d31f commit 281ddcb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# renv 1.1.0 (UNRELEASED)

* Fixed an issue where `renv` failed to restore packages installed from
r-universe when the associated lockfile record had no `RemoteRef` field.
(#2068)

* `renv` now detects dependencies from usages of `utils::citation()`. (#2047)

* Fixed an issue where packages installed from r-universe via an explicit
Expand Down
24 changes: 12 additions & 12 deletions R/retrieve.R
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ renv_retrieve_repos <- function(record) {

# if this is a package from r-universe, try restoring from github
# (currently inferred from presence for RemoteUrl field)
unifields <- c("RemoteUrl", "RemoteRef", "RemoteSha")
unifields <- c("RemoteUrl", "RemoteSha")
if (all(unifields %in% names(record)))
methods$push(renv_retrieve_git)
else
Expand Down Expand Up @@ -783,17 +783,17 @@ renv_retrieve_repos_error_report <- function(record, errors) {
}

renv_retrieve_url_resolve <- function(record) {

# https://github.com/rstudio/renv/issues/2060
pkgref <- record$RemotePkgRef
if (!is.null(pkgref)) {
remote <- renv_remotes_parse(pkgref)
if (identical(remote$type, "url"))
return(remote$url)
}

record$RemoteUrl

}

renv_retrieve_url <- function(record) {
Expand Down Expand Up @@ -939,16 +939,16 @@ renv_retrieve_repos_archive_root <- function(url, record) {
if (!is.null(result))
return(result)
}

# retrieve the appropriate formatter for this repository url
formatter <- memoize(
key = url,
value = renv_retrieve_repos_archive_formatter(url)
)

# use it
formatter(url, record)

}

renv_retrieve_repos_archive_formatter <- function(url) {
Expand All @@ -960,34 +960,34 @@ renv_retrieve_repos_archive_formatter <- function(url) {
cran = function(repo, record) {
with(record, file.path(repo, "src/contrib/Archive", Package))
},

# format used by older releases of Artifactory
# https://github.com/rstudio/renv/issues/602
# https://github.com/rstudio/renv/issues/1996
artifactory = function(repo, record) {
with(record, file.path(repo, "src/contrib/Archive", Package, Version))
},

# format used by Nexus
# https://github.com/rstudio/renv/issues/595
nexus = function(repo, record) {
with(record, file.path(repo, "src/contrib"))
}

)

# check for an override
override <- getOption("renv.repos.formatters")
if (!is.null(override)) {
formatter <- formatters[[override[[url]] %||% ""]]
if (!is.null(formatter))
return(formatter)
}

# build URL to PACKAGES file in src/contrib
pkgurl <- file.path(url, "src/contrib/PACKAGES")
headers <- renv_download_headers(pkgurl)

# use the headers to infer the repository type
if ("x-artifactory-id" %in% names(headers)) {
formatters[["cran"]]
Expand Down

0 comments on commit 281ddcb

Please sign in to comment.