-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix transient symlinks overriding direct ones v2 #5016
Fix transient symlinks overriding direct ones v2 #5016
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%)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! What do you think about my suggestion?
src/package-linker.js
Outdated
return -1; | ||
} | ||
return 0; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
@arcanis think we can merge this? |
Totally! This will be in the next release, hopefully today or tomorrow 👍 |
…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) ...
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.