don't upgrade transitive dependencies when installing with pak (#2329)#2330
Merged
Conversation
renv_pak_install() passed upgrade = TRUE to pak, which upgraded every transitively-resolved dependency to the latest version -- including recommended packages such as 'cluster' and 'Matrix' that ship with R and carried no version constraint. This diverged from renv's native installer, which leaves already-satisfied dependencies alone, and could trigger a needless (and sometimes failing) rebuild of a recommended package when installing an unrelated one. Pass upgrade = FALSE instead, and append the 'reinstall' pak parameter to explicitly-requested packages so they are still (re)installed even when already current -- matching the native installer, which always installs explicit requests. Transitive dependencies are now only upgraded when a constraint requires it. The no-arg update path (renv_pak_update) keeps upgrade = TRUE.
554e267 to
05b235c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2329.
Problem
renv::install()with pak enabled upgrades already-installed dependencies that are only pulled in transitively. Most visibly this affects recommended packages (e.g.cluster,Matrix) that ship with R: installing an unrelated package likecluewould drag inclusterand, because renv forcedupgrade = TRUE, pak would upgrade/rebuild it even thoughclueimposed no version constraint. In the reported case that rebuild then failed to compile locally.The root cause is that
renv_pak_install()passedupgrade = TRUEtopak::pkg_install(). pak's default isupgrade = FALSE, which does the minimum work to satisfy the request: it installs/upgrades the explicitly-requested packages to the latest version, but leaves already-installed dependencies alone unless a constraint requires a newer one. Forcingupgrade = TRUEoverrode that and upgraded everything, diverging from renv's own native installer (renv_graph_needs_update), which leaves already-satisfied dependencies alone.Fix
Pass
upgrade = FALSEinrenv_pak_install(), matching pak's default and renv's native installer.To preserve the one useful property of
upgrade = TRUE-- that an explicit request is always acted upon -- append thereinstallpak parameter to explicitly-requested packages. This mirrors renv's native installer, which always (re)installs explicitly-requested packages (renv_restore_findreturns""for anything instate$packages). Verified behaviors against pak 0.10.0:The query parameter is appended following pkgdepends' own model (everything after the first
?is an&-separated query), so a spec that already carries a query (e.g.bread?nocache) is extended with&rather than a malformed second?.The no-arg "update everything" path (
renv_pak_update) is unchanged and still usesupgrade = TRUE.Tests
Added to
tests/testthat/test-pak.R:pkg?reinstallwithupgrade = FALSE;&reinstallappended (not a second?);toastdoes not upgrade an already-installed, dependency-satisfyingbread.Full pak suite passes (37 passed, 0 failed, 0 skipped).