-
Notifications
You must be signed in to change notification settings - Fork 3k
npm@3 given the same module list, not linking in same order #8995
Comments
I haven't been able to reproduce this one, but as an ordering bug I think some quality time thinking about the code will find the problem area. |
Any ETA on fixing this? We aren't able to release gulp 4.0 until this is fixed |
im waitin gulp4 for almost one year, pls fix it 🐱 |
I would love the gulp folks to provide some explanation for why this is a blocker for them. This was, if anything, worse in npm@2. |
Looking back in gulpjs/gulp-cli#7 it looks like npm@2 used to just explode. With #8996 this may be good enough. And digging into gulpjs/gulp-cli#7 I'd really like to see this reproduced with a current release, as I'm skeptical that it can still happen– binaries are linked into place by the
|
#!/bin/sh
counter=0
function install {
let counter++
npm install gulp gulp-cli > /dev/null && printf "install $counter, gulp bin -> " && readlink node_modules/.bin/gulp && install
}
echo "Running 'npm install gulp gulp-cli' repeatedly"
rm -fr node_modules
install With npm 3.2.2 I get this output: Running 'npm install gulp gulp-cli' repeatedly
install 1, gulp bin -> ../gulp-cli/bin/gulp.js
install 2, gulp bin -> ../gulp/bin/gulp.js
install 3, gulp bin -> ../gulp/bin/gulp.js
install 4, gulp bin -> ../gulp/bin/gulp.js
install 5, gulp bin -> ../gulp/bin/gulp.js
install 6, gulp bin -> ../gulp/bin/gulp.js
install 7, gulp bin -> ../gulp/bin/gulp.js |
Ok, what I see is deterministic ordering for the initial run, and for the additional runs, but a difference between the first run and those additional runs. |
So followup runs consistently produce this order:
Which is consistent with @heikki's output and with theory (we there are no cross module dependencies we sort by path length). |
Likewise a fresh install consistently produces this order: (gulp and gulp-cli are installed last after allll their deps)
|
I think the latter is happening due to gulp being a dev-dep of gulp-cli. The question is, why doesn't this rule also apply with the first scenario. |
Scheduling this for Aug 20th's release. |
Excellent, thanks! |
The install order is determined by: 1) The location of the thing to be installed relative to the root module. 2) Dependency order, such that a -> b -> c will install modules as: c, b, a 1 is deterministic, regardless of what's being installed. But 2 can change the order of things higher in the dep tree. Eg, b, or a might get sorted earlier if c requires them. This mostly doesn't matter, but it does mean that if you have two modules with conflicting bins, they _can_ get installed in different orders. This changes sorts all of the top level modules to be LAST, in location order (1), and then sorts all the rest per (2). This ensures that top level modules have a deterministic install order. (Non top level modules can't have bin conflicts as that's treated the same as a version conflict and the conflicting module would be hoisted.) PR-URL: #9274 Fixes: #8995
The install order is determined by: 1) The location of the thing to be installed relative to the root module. 2) Dependency order, such that a -> b -> c will install modules as: c, b, a 1 is deterministic, regardless of what's being installed. But 2 can change the order of things higher in the dep tree. Eg, b, or a might get sorted earlier if c requires them. This mostly doesn't matter, but it does mean that if you have two modules with conflicting bins, they _can_ get installed in different orders. This changes sorts all of the top level modules to be LAST, in location order (1), and then sorts all the rest per (2). This ensures that top level modules have a deterministic install order. (Non top level modules can't have bin conflicts as that's treated the same as a version conflict and the conflicting module would be hoisted.) PR-URL: #9274 Fixes: #8995
Landed as d395a6b, included in |
As per @iarna at gulpjs/gulp-cli#7 (comment)
I haven't tested this, but a gulp core contributor tested and linked results at gulpjs/gulp-cli#7 (comment)
The text was updated successfully, but these errors were encountered: