diff --git a/DESCRIPTION b/DESCRIPTION index 0f88c74b..cda992c3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,7 @@ URL: https://Require.predictiveecology.org, https://github.com/PredictiveEcology/Require Date: 2026-09-04 -Version: 2.1.1.9052 +Version: 2.1.1.9053 Authors@R: c( person(given = "Eliot J B", family = "McIntire", diff --git a/NEWS.md b/NEWS.md index 8f2f12fa..42a01645 100644 --- a/NEWS.md +++ b/NEWS.md @@ -24,6 +24,8 @@ ## Bug fixes +* Two GitHub refs for one package on different branches, each with a minimum version, now keep the higher minimum. Require kept whichever came first, so a module's `PredictiveEcology/mpbutils@development (>= 0.1.3.9003)` was dropped behind another module's `PredictiveEcology/mpbutils (>= 0.1.2)`, and the installed 0.1.3.9002 was never upgraded. + * When pak's batch install fails without naming the package at fault, the packages left are installed one at a time as before, but now in dependency order and with the same retry passes as a package pak does name. They were tried once each in the order given, so a package tried before its dependency (BioSIM before J4R, LandR before pemisc) was reported as not installed. * An exact version together with a minimum and a maximum for the same package, e.g. `c("pkg (==2.0)", "pkg (>=1.0)", "pkg (<=3.0)")`, no longer stops `Require()` with "invalid argument type". The exact version is kept when it meets both; otherwise it is dropped as before. diff --git a/R/pak.R b/R/pak.R index ebad179a..f1760a27 100644 --- a/R/pak.R +++ b/R/pak.R @@ -3119,7 +3119,8 @@ reportInstallFailures <- function(failures, missingPkgNames = character(0), # listed before the @HEAD/bare form). If no GitHub ref exists for a # duplicate, keep the first occurrence. # Copies of the kept ref that add a version spec are kept too, so -# trimRedundancies() can apply the strictest spec. +# trimRedundancies() can apply the strictest spec; so is any other GitHub ref +# with a version spec (another branch), so trimRedundancies() can choose it. # # Why this exists: trimRedundancies()'s logic for collapsing duplicate # package rows relies on `versionSpec` (e.g. `(>= 1.0)`) being set on at @@ -3150,7 +3151,11 @@ reportInstallFailures <- function(failures, missingPkgNames = character(0), ## behind an unversioned "acct/LandR@dev", so LandR below X was never upgraded. hasSpec <- grepl("\\([[:space:]]*[<>=]", refs[idx]) sameRef <- trimVersionNumber(refs[idx]) == trimVersionNumber(refs[keep]) - toRemove <- c(toRemove, setdiff(idx, c(keep, idx[hasSpec & sameRef]))) + ## Likewise a GitHub ref on another branch with a version spec: keeping only + ## the first lost a module's "acct/mpbutils@development (>= X)" behind + ## another module's "acct/mpbutils (>= Y)", so mpbutils below X was never + ## upgraded. trimRedundancies() picks between branches by version. + toRemove <- c(toRemove, setdiff(idx, c(keep, idx[hasSpec & (sameRef | isGH(refs[idx]))]))) } if (length(toRemove)) refs[-toRemove] else refs } diff --git a/tests/testthat/test-15bugfixes_testthat.R b/tests/testthat/test-15bugfixes_testthat.R index 47218e4c..61fdf808 100644 --- a/tests/testthat/test-15bugfixes_testthat.R +++ b/tests/testthat/test-15bugfixes_testthat.R @@ -791,6 +791,16 @@ test_that(".preferGHrefDedup() collapses multi-form refs preferring GH > CRAN", "acct/pkg@dev (>= 1.2.0.9046)", "acct/pkg")), c("acct/pkg@dev", "acct/pkg@dev (>= 1.2.0.9046)")) + # Another branch's GitHub ref with a higher version floor is kept too, so + # trimRedundancies() can choose it (2026-12-04: four MPB modules asked for + # "PredictiveEcology/mpbutils (>= 0.1.2)" and one for + # "PredictiveEcology/mpbutils@development (>= 0.1.3.9003)"; the first was + # kept, and mpbutils 0.1.3.9002 was never upgraded). + refs3 <- c("acct/pkg (>= 0.1.2)", "acct/pkg@dev (>= 0.1.3.9003)") + expect_identical(Require:::.preferGHrefDedup(refs3), refs3) + expect_identical(Require:::trimRedundancies(Require:::.preferGHrefDedup(refs3))$packageFullName, + "acct/pkg@dev (>= 0.1.3.9003)") + # No-op when there are no duplicates. refs2 <- c("data.table", "fpCompare", "digest") expect_identical(Require:::.preferGHrefDedup(refs2), refs2)