Skip to content

fix(arborist): propagate overrides through Link nodes to targets#9254

Merged
owlstronaut merged 1 commit intorelease/v11from
backport/v11/9198
Apr 22, 2026
Merged

fix(arborist): propagate overrides through Link nodes to targets#9254
owlstronaut merged 1 commit intorelease/v11from
backport/v11/9198

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Backport of #9198 to release/v11.

In continuation of our exploration of using `install-strategy=linked` in
the [Gutenberg
monorepo](WordPress/gutenberg#75814), which
powers the WordPress Block Editor.

When using `install-strategy=linked`, npm overrides for transitive
dependencies were ignored.
The overridden version was installed but reported as `invalid` instead
of `overridden`, and with `strict-peer-deps` the install failed entirely
with `ERESOLVE`.

The root cause is that override propagation stops at Link nodes and
never reaches their targets.
Overrides propagate through the tree via `addEdgeIn` ->
`updateOverridesEdgeInAdded` -> `recalculateOutEdgesOverrides`.
When a Link node receives overrides, `recalculateOutEdgesOverrides`
iterates over `this.edgesOut` — but Links have no `edgesOut` (their
targets do).
So overrides never reach the target node's dependency edges, and those
edges use `rawSpec` instead of the overridden spec.

In the linked strategy, all packages in `node_modules/` are Links
pointing to targets in `.store/`.
This meant no overrides propagated past the first level of the
dependency tree.

The fix overrides `recalculateOutEdgesOverrides` in the `Link` class to
forward overrides to the target node.
When `buildIdealTree` creates a root Link (e.g. on macOS where `/tmp` ->
`/private/tmp`), the target Node is now created with `loadOverrides:
true` so it loads override rules from `package.json`.

The `#applyRootOverridesToWorkspaces` workaround method is removed — it
was compensating for this exact bug by detaching workspace edges whose
specs didn't match. With proper propagation, workspace edges already
have the correct overridden spec, making the workaround dead code.

## References

Fixes #9197

(cherry picked from commit bc32d94)
@wraithgar wraithgar closed this Apr 17, 2026
@wraithgar wraithgar reopened this Apr 17, 2026
@owlstronaut owlstronaut merged commit e7805c3 into release/v11 Apr 22, 2026
35 checks passed
@owlstronaut owlstronaut deleted the backport/v11/9198 branch April 22, 2026 20:56
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.

3 participants