Skip to content

fix: keep the requested version when retrying install after EACCES - #3379

Open
arpitjain099 wants to merge 1 commit into
nodejs:mainfrom
arpitjain099:fix/eacces-retry-version
Open

arpitjain099 wants to merge 1 commit into
nodejs:mainfrom
arpitjain099:fix/eacces-retry-version

Conversation

@arpitjain099

Copy link
Copy Markdown
Description of change

eaccesFallback retries the install with gyp.commands.install([noretry].concat(argv)), putting the sentinel first. processRelease reads the version from argv[0], so on the retry semver.valid('--node_gyp_internal_noretry') is null and the requested version falls through to process.version.

The result is that node-gyp install <version> under EACCES quietly installs headers for the running node instead, and exits 0. Against a local dist server:

$ node bin/node-gyp.js install 99.0.0 --devdir=<unwritable> --dist-url=http://127.0.0.1:51423
gyp WARN EACCES attempting to reinstall using temporary dev dir ...
gyp http GET http://127.0.0.1:51423/v22.20.0/node-v22.20.0-headers.tar.gz

With the sentinel moved to the end the same command fetches v99.0.0.

It is narrow: --target and npm_config_target go through gyp.opts.target and are unaffected, so it only bites the positional argument form.

The existing EACCES retry once case calls install([]) and asserts on the stat count, so it cannot see this. The new case records the argv of each retry and checks the version is still first, which fails on main with '--node_gyp_internal_noretry' == '99.0.0'.

npm test passes, 115 tests, and eslint is clean on both files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant