Skip to content

fix(arborist): only forward Link overrides when a rule names a target dep#9359

Open
manzoorwanijk wants to merge 1 commit into
npm:latestfrom
manzoorwanijk:fix/link-overrides-skip-when-no-matching-rule
Open

fix(arborist): only forward Link overrides when a rule names a target dep#9359
manzoorwanijk wants to merge 1 commit into
npm:latestfrom
manzoorwanijk:fix/link-overrides-skip-when-no-matching-rule

Conversation

@manzoorwanijk
Copy link
Copy Markdown
Contributor

In continuation of our exploration of using install-strategy=linked in the Gutenberg monorepo, which powers the WordPress Block Editor.

npm ci in v11.14.x rejects lockfiles that v11.13.x accepts, with EUSAGE: Invalid: lock file's <pkg>@<old> does not satisfy <pkg>@<new> for any workspace ^ range that has had a newer matching patch published since the lockfile was generated.

Bisected to commit e7805c3 (#9198). The new Link.recalculateOutEdgesOverrides was forwarding the link's OverrideSet to the target unconditionally — even when the OverrideSet had no rule naming any of the target's deps. That set target.overrides from undefined to the root's generic OverrideSet, and the cascade caused canReplaceWith's "overrides equal" branch to flip placeDep's decision from KEEP to REPLACE for an edge the lockfile already satisfied. validateLockfile then rejected the resulting ideal tree.

Fixed by gating the forward on the OverrideSet actually containing a rule that names a dep the target depends on. If no rule matches, don't forward — target.overrides stays undefined and downstream placement matches v11.13.0.

#9198's intent is preserved: when the override DOES name a dep of the target, propagation still fires. #9198's existing test still passes (including bar edge spec is overridden to 2.0.0). Added a regression test for the no-matching-rule case; verified failing before this fix and passing after.

References

Fixes #9357
Refines #9198

@manzoorwanijk manzoorwanijk marked this pull request as ready for review May 14, 2026 18:42
@manzoorwanijk manzoorwanijk requested review from a team as code owners May 14, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] npm ci re-resolves workspace deps from the registry in v11.14.x, fails on lockfiles v11.13.x accepts

1 participant