Fix transient symlinks overriding direct ones v2#5016
Merged
arcanis merged 5 commits intoyarnpkg:masterfrom Jan 15, 2018
Merged
Fix transient symlinks overriding direct ones v2#5016arcanis merged 5 commits intoyarnpkg:masterfrom
arcanis merged 5 commits intoyarnpkg:masterfrom
Conversation
If a transient dependency has a bin link with the same name as a direct dependency, sometimes the top level bin link with lead to the transient dependency rather than the direct one after install. This test asserts that bin links from direct dependencies are installed.
The bin links are created in two passes during install. In the first pass all direct dependencies for the installing module and transient dependencies are created in their respective bin directories. In the second pass top level bin links are created for all modules, including transient dependencies. This patch makes sure the second pass doesn't overwrite links from the first pass which fixes a problem where links from transient dependencies could overwrite links from direct dependencies.
…x for bin link ordering.
|
This change will increase the build size from 10.26 MB to 10.26 MB, an increase of 2.94 KB (0%)
|
arcanis
reviewed
Dec 4, 2017
Member
arcanis
left a comment
There was a problem hiding this comment.
Thanks! What do you think about my suggestion?
| return -1; | ||
| } | ||
| return 0; | ||
| }); |
Member
There was a problem hiding this comment.
What do you think about splitting the array rather than doing a full sort? The algorithmic complexity would be better:
let transientBins = [], topLevelBins = [];
for (let ... of Array.from(linksToCreate.values())) {
if (isDirectRequire) {
topLevelBins.push();
} else {
transientBins.push();
}
}
return [... transientBins, ... topLevelBins];
Contributor
Author
There was a problem hiding this comment.
I like that. The code is easier to read.
|
This bug is still present in master (fb6511c) and is blocking us from switching to yarn. Is there anything I can do to help move this PR forward? |
Contributor
Author
|
@arcanis think we can merge this? |
Member
|
Totally! This will be in the next release, hopefully today or tomorrow 👍 |
arcanis
approved these changes
Jan 15, 2018
agoldis
added a commit
to agoldis/yarn
that referenced
this pull request
Feb 2, 2018
…readdir_files * upstream/master: (34 commits) feat(upgrade, add): Separately log added/upgraded dependencies (yarnpkg#5227) feat(publish): Publish command uses publishConfig.access in package.json (yarnpkg#5290) fix(CLI): Use process exit instead of exitCode for node < 4 (yarnpkg#5291) feat(cli): error on missing workspace directory (yarnpkg#5206) (yarnpkg#5222) feat: better error when package is not found (yarnpkg#5213) Allow scoped package as alias source (yarnpkg#5229) fix(cli): Use correct directory for upgrade-interactive (yarnpkg#5272) nohoist baseline implementation (yarnpkg#4979) 1.4.1 1.4.0 Show current version, when new version is not supplied on "yarn publish" (yarnpkg#4947) fix(install): use node-gyp from homebrew npm (yarnpkg#4994) Fix transient symlinks overriding direct ones v2 (yarnpkg#5016) fix(auth): Fixes authentication conditions and logic with registries (yarnpkg#5216) chore(package): move devDeps to appropriate place (yarnpkg#5166) fix(resolution) Eliminate "missing peerDep" warning when dep exists at root level. (yarnpkg#5088) fix(cli): improve guessing of package names that contain a dot (yarnpkg#5102) (yarnpkg#5135) feat(cli): include notice with license when generating disclaimer (yarnpkg#5072) (yarnpkg#5111) feat(cli): group by license in licenses list (yarnpkg#5074) (yarnpkg#5110) feat(cli): improve error message when file resolver can't find file (yarnpkg#5134) (yarnpkg#5145) ...
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.
Summary
This PR is a replacement for #5012 with a different fix.
fixes #4937
Added a sort to the top level bin links to ensure that direct dependencies are linked last. Since bin links are overwritten if they already exist, this will ensure that direct deps bin links will overwrite transitive ones.
Test plan
Run the test suite.