fix(exec): resolve workspace-local bin under the linked install strategy#9639
Merged
owlstronaut merged 1 commit intoJun 24, 2026
Merged
Conversation
12ebf3a to
8f6667e
Compare
c4ab8a3 to
1a0596e
Compare
Contributor
Author
|
The coverage is broken in EDIT: Resolved by #9646 |
1a0596e to
86c6fd5
Compare
owlstronaut
approved these changes
Jun 24, 2026
Contributor
|
🎉 Backport to |
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.
In continuation of our exploration of using
install-strategy=linkedin the Gutenberg monorepo, which powers the WordPress Block Editor.Under
install-strategy=linked,npm exec -w <ws> -- <bin>ignored a workspace-local bin (provided by a sibling workspace dependency) and fell through to the registry, producing a spuriousE404. The hoisted strategy ran the local bin correctly.Why
For a workspace exec, the command computed the local bin directory as
resolve(this.npm.localDir, name, 'node_modules', '.bin'), i.e.<root>/node_modules/<name>/node_modules/.bin. That path only resolves when the workspace is symlinked into the rootnode_modulesas<name>, which is how the hoisted strategy lays workspaces out. The linked strategy does not hoist workspaces into the rootnode_modules; the workspace's real bin lives at<workspace>/node_modules/.bin. libnpmexec walks up from the given bin directory looking fornode_modules/.bin/<bin>, so starting from the nonexistent hoisted path never reached the workspace's actual bin and the lookup fell back to the registry.How
Base the local bin directory on the workspace's own path (
runPath) instead of the hoistedlocalDir/<name>location. This is correct under both strategies: linked finds the bin in the workspace'snode_modules/.bin, and hoisted still finds the root-hoisted bin because the walk-up continues from the workspace directory to the rootnode_modules/.bin.References
Fixes #9616