From 37613e4e686e4891210acaabc9c23f41456eda3f Mon Sep 17 00:00:00 2001 From: Gar Date: Mon, 1 Feb 2021 13:40:44 -0800 Subject: [PATCH 1/5] fix(exec): use latest version when possible pull latest packument when getting info about package to run, also install newer version if one is available and user has not specified a version (i.e. is defaulting to @latest) PR-URL: https://github.com/npm/cli/pull/2592 Credit: @wraithgar Closes: #2395 Closes: #2329 Reviewed-by: @darcyclarke --- lib/exec.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/exec.js b/lib/exec.js index d36dd87cfb971..e90ec0866e4dd 100644 --- a/lib/exec.js +++ b/lib/exec.js @@ -169,8 +169,12 @@ const exec = async args => { return await readPackageJson(pj) } catch (er) {} } + // Force preferOnline to true so we are making sure to pull in the latest + // This is especially useful if the user didn't give us a version, and + // they expect to be running @latest return await pacote.manifest(p, { ...npm.flatOptions, + preferOnline: true, }) })) @@ -193,9 +197,13 @@ const exec = async args => { const arb = new Arborist({ ...npm.flatOptions, path: installDir }) const tree = await arb.loadActual() - // any that don't match the manifest we have, install them - // add installDir/node_modules/.bin to pathArr - const add = manis.filter(mani => manifestMissing(tree, mani)) + // at this point, we have to ensure that we get the exact same + // version, because it's something that has only ever been installed + // by npm exec in the cache install directory + const add = manis.filter(mani => manifestMissing(tree, { + ...mani, + _from: `${mani.name}@${mani.version}`, + })) .map(mani => mani._from) .sort((a, b) => a.localeCompare(b)) From 64370970653af5c8d7a2be2c2144e355aa6431b0 Mon Sep 17 00:00:00 2001 From: Darcy Clarke Date: Tue, 2 Feb 2021 11:40:03 -0500 Subject: [PATCH 2/5] @npmcli/config@1.2.9 --- node_modules/@npmcli/config/lib/set-envs.js | 8 +------- node_modules/@npmcli/config/package.json | 2 +- package-lock.json | 14 +++++++------- package.json | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/node_modules/@npmcli/config/lib/set-envs.js b/node_modules/@npmcli/config/lib/set-envs.js index 089333796163e..36d37145466e0 100644 --- a/node_modules/@npmcli/config/lib/set-envs.js +++ b/node_modules/@npmcli/config/lib/set-envs.js @@ -53,13 +53,7 @@ const setEnvs = (config) => { list: [cliConf, envConf], } = config - const { DESTDIR } = env - if (platform !== 'win32' && DESTDIR && globalPrefix.indexOf(DESTDIR) === 0) - env.PREFIX = globalPrefix.substr(DESTDIR.length) - else - env.PREFIX = globalPrefix - - env.INIT_CWD = env.INIT_CWD || process.cwd() + env.INIT_CWD = process.cwd() // if the key is the default value, // if the environ is NOT the default value, diff --git a/node_modules/@npmcli/config/package.json b/node_modules/@npmcli/config/package.json index a7050c73a03ef..644544a49d869 100644 --- a/node_modules/@npmcli/config/package.json +++ b/node_modules/@npmcli/config/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/config", - "version": "1.2.8", + "version": "1.2.9", "files": [ "lib" ], diff --git a/package-lock.json b/package-lock.json index 2697874fb5e44..dc4f0b2d30fbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -360,7 +360,7 @@ "dependencies": { "@npmcli/arborist": "^2.1.1", "@npmcli/ci-detect": "^1.2.0", - "@npmcli/config": "^1.2.8", + "@npmcli/config": "^1.2.9", "@npmcli/run-script": "^1.8.1", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", @@ -727,9 +727,9 @@ "inBundle": true }, "node_modules/@npmcli/config": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.2.8.tgz", - "integrity": "sha512-XFqg1uxUhEiy73hT1Z66xrMojgUOzAaCCYm12bEYBbi3wxmaer8MDRQ8ZViCacHFSZhkLVLqt/osPwKKJPduPw==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.2.9.tgz", + "integrity": "sha512-d7mx35ju9HFg0gNHiwMU0HXCJk1esAeRdMktLeD+K2K2awkZyEm1FyX+g8iuZbmWGAaFP/aGiXo7a0lKlmp6Xg==", "inBundle": true, "dependencies": { "ini": "^2.0.0", @@ -9962,9 +9962,9 @@ "integrity": "sha512-oN3y7FAROHhrAt7Rr7PnTSwrHrZVRTS2ZbyxeQwSSYD0ifwM3YNgQqbaRmjcWoPyq77MjchusjJDspbzMmip1Q==" }, "@npmcli/config": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.2.8.tgz", - "integrity": "sha512-XFqg1uxUhEiy73hT1Z66xrMojgUOzAaCCYm12bEYBbi3wxmaer8MDRQ8ZViCacHFSZhkLVLqt/osPwKKJPduPw==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.2.9.tgz", + "integrity": "sha512-d7mx35ju9HFg0gNHiwMU0HXCJk1esAeRdMktLeD+K2K2awkZyEm1FyX+g8iuZbmWGAaFP/aGiXo7a0lKlmp6Xg==", "requires": { "ini": "^2.0.0", "mkdirp-infer-owner": "^2.0.0", diff --git a/package.json b/package.json index 57b7f48964b81..e7cdc11d0bdfd 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "dependencies": { "@npmcli/arborist": "^2.1.1", "@npmcli/ci-detect": "^1.2.0", - "@npmcli/config": "^1.2.8", + "@npmcli/config": "^1.2.9", "@npmcli/run-script": "^1.8.1", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", From 567c9bd03a7669111fbba6eb6d1f12ed7cad5a1b Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 2 Feb 2021 09:11:21 -0800 Subject: [PATCH 3/5] fix(lib/npm): do not clobber config.execPath If we were not asked to clobber config.execPath, don't do it. Credit: @wraithgar Reviewed-by: @isaacs --- lib/npm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/npm.js b/lib/npm.js index 7a15a29b2fed9..40aa9bbd9b506 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -173,8 +173,8 @@ const npm = module.exports = new class extends EventEmitter { if (node && node.toUpperCase() !== process.execPath.toUpperCase()) { log.verbose('node symlink', node) process.execPath = node + this.config.execPath = node } - this.config.execPath = node await this.config.load() this.argv = this.config.parsedArgv.remain From 1406e193618d1435f61d77bf71ba5066ad6fef34 Mon Sep 17 00:00:00 2001 From: Darcy Clarke Date: Tue, 2 Feb 2021 12:25:34 -0500 Subject: [PATCH 4/5] docs: changelog for v7.5.2 --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b826517edba..888c799bee253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +## v7.5.2 (2021-02-02) + +### BUG FIXES + +* [`37613e4e6`](https://github.com/npm/cli/commit/37613e4e686e4891210acaabc9c23f41456eda3f) +[#2395](https://github.com/npm/cli/issues/2395) +[#2329](https://github.com/npm/cli/issues/2329) +fix(exec): use latest version when possible +([@wraithgar](https://github.com/wraithgar)) +* [`567c9bd03`](https://github.com/npm/cli/commit/567c9bd03a7669111fbba6eb6d1f12ed7cad5a1b) +fix(lib/npm): do not clobber config.execPath +([@wraithgar](https://github.com/wraithgar)) + +### DEPENDENCIES + +* [`643709706`](https://github.com/npm/cli/commit/64370970653af5c8d7a2be2c2144e355aa6431b0) +`@npmcli/config@1.2.9` ([@isaacs](https://github.com/isaacs)) + * [`4c6be4a`](https://github.com/npm/config/commit/4c6be4a66a3e89ae607e08172b8543b588a95fb5) Restore npm v6 behavior with `INIT_CWD` + * [`bbebc66`](https://github.com/npm/config/commit/bbebc668888f71dba57959682364b6ff26ff4fac) Do not set the `PREFIX` environment variable + ## v7.5.1 (2021-02-01 ### BUG FIXES From c1589c160e95700c3dad9467a045d998bb8c23c8 Mon Sep 17 00:00:00 2001 From: Darcy Clarke Date: Tue, 2 Feb 2021 12:26:16 -0500 Subject: [PATCH 5/5] 7.5.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index dc4f0b2d30fbc..eecef9bdf2af7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "npm", - "version": "7.5.1", + "version": "7.5.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "npm", - "version": "7.5.1", + "version": "7.5.2", "bundleDependencies": [ "@npmcli/arborist", "@npmcli/ci-detect", diff --git a/package.json b/package.json index e7cdc11d0bdfd..2eecfdbfc0456 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "7.5.1", + "version": "7.5.2", "name": "npm", "description": "a package manager for JavaScript", "keywords": [