fix: local transitive dependencies with --install-links=true #8436
+272
−1
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.
Fix: Local transitive dependencies with --install-links=true
Problem Statement
Issue #5733:
npm install --install-links=true
fails when projects have local transitive dependencies (file dependencies that reference other packages within the same project root).Root Cause: The dependency resolution logic in
build-ideal-tree.js
treated allfile:
dependencies identically, without distinguishing between project-internal dependencies (which should always be symlinked) and external file dependencies (which should respect theinstallLinks
setting).Solution
This PR adds logic to detect project-internal file dependencies and ensures they are always symlinked, regardless of the
installLinks
setting, while external file dependencies continue to respect the user's preference.Key Changes
File:
workspaces/arborist/lib/arborist/build-ideal-tree.js
Behavior Matrix
Comparison with Previous Fix Attempt
Technical Details
Detection Logic: A file dependency is considered project-internal if its resolved target path is within or equal to the project root directory.
Integration Point: The fix integrates cleanly into the existing
#nodeFromSpec()
method's link vs copy decision logic without requiring changes to other parts of the codebase.Risk Assessment
Low Risk: This is a targeted fix that only affects the specific broken use case. All existing functionality is preserved, and the change is isolated to a single decision point in the dependency resolution flow.