Skip to content

Commit

Permalink
fix issue with hydrate (#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Aug 20, 2024
1 parent d6bced3 commit 352b28e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# renv (development version)

* Fixed an issue where `renv::hydrate()` did not hydrate packages which
were also listed as dependencies within a project's `DESCRIPTION` file.
(#1970)

* Fixed an issue where `renv::checkout()` omitted some fields from lockfile
records when using `actions = c("snapshot", "restore")`. (#1969)

Expand Down
10 changes: 8 additions & 2 deletions R/hydrate.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@ hydrate <- function(packages = NULL,
# figure out required packages which aren't installed
missing <- deps[!nzchar(deps)]

# also consider remotes; treat these as 'missing' so we always try to install them
remotes <- renv_project_remotes(project = project, resolve = TRUE)
# also consider remotes; if a package is listed within Remotes,
# then choose to install that package instead of linking it
filter <- function(specs, remotes) {
packages <- map_chr(remotes, `[[`, "Package")
keep(specs, packages)
}

remotes <- renv_project_remotes(project, filter = filter, resolve = TRUE)
missing[map_chr(remotes, `[[`, "Package")] <- ""

# remove base + missing packages
Expand Down
14 changes: 9 additions & 5 deletions R/project.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,13 @@ renv_project_type_impl <- function(path) {

}

renv_project_remotes <- function(project, fields = NULL, resolve = FALSE) {
renv_project_remotes <- function(project, filter = NULL, resolve = FALSE) {

descpath <- file.path(project, "DESCRIPTION")
if (!file.exists(descpath))
return(NULL)

# first, parse remotes (if any)
remotes <- renv_description_remotes(descpath)

# next, find packages mentioned in the DESCRIPTION file
# find packages mentioned in the DESCRIPTION file
deps <- renv_dependencies_discover_description(
path = descpath,
project = project
Expand Down Expand Up @@ -140,6 +137,13 @@ renv_project_remotes <- function(project, fields = NULL, resolve = FALSE) {
}
}

# parse remotes if available
remotes <- renv_description_remotes(descpath)

# apply filter
if (!is.null(filter))
specs <- filter(specs, remotes)

# now, try to resolve the packages
records <- enumerate(specs, function(package, spec) {

Expand Down

0 comments on commit 352b28e

Please # to comment.