Skip to content
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 infinite install loop. #1384

Merged
merged 1 commit into from
Feb 27, 2018
Merged

Fix infinite install loop. #1384

merged 1 commit into from
Feb 27, 2018

Conversation

bnoordhuis
Copy link
Member

Retry the download+install dance only once after encountering an EACCES.

That only happens when both the devdir (usually: $HOME/.node-gyp) and
the current working directory aren't writable. Users won't often hit
that except through sudo npm install because npm drops privileges
before executing node-gyp.

Fixes #1383.

Copy link
Member

@gibfahn gibfahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo testing question:

would it be possible to call node-gyp with npm_config_devdir set to a tmpdir, and chmod 000 the directory before running the test (and obviously chmod it back afterwards)?

function eaccesFallback () {
function eaccesFallback (err) {
var noretry = '--node_gyp_internal_noretry'
if (-1 !== argv.indexOf(noretry)) return cb(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking Bikeshed:

Using a yoda expression and a one-line if statement seems odd here. The yoda is presumably to make it easier to read, but squashing onto one line makes it harder to read.

if (-1 !== argv.indexOf(noretry)) return cb(err)
if (argv.indexOf(noretry) !== -1) {
  return cb(err)
}

nbd, more curious than anything else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like my guard statements on one line, mainly for greppability.

@bnoordhuis
Copy link
Member Author

I added a test that skirts around doing actual I/O, PTAL.

@bnoordhuis
Copy link
Member Author

}

gyp.commands.install([], function (err) {
t.ok(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this test be removed and the test count reduced to 2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you want to know that the final callback is called, right? Or do I misunderstand you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point.

@bnoordhuis
Copy link
Member Author

https://ci.nodejs.org/job/nodegyp-test-pull-request/44/ - unbreak another test.

Retry the download+install dance only once after encountering an EACCES.

That only happens when both the devdir (usually: `$HOME/.node-gyp`) and
the current working directory aren't writable.  Users won't often hit
that except through `sudo npm install` because npm drops privileges
before executing node-gyp.

Fixes: #1383
PR-URL: #1384
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
@bnoordhuis bnoordhuis closed this Feb 27, 2018
@bnoordhuis bnoordhuis deleted the fix1383 branch February 27, 2018 23:04
@bnoordhuis bnoordhuis merged commit 8b7ccfe into nodejs:master Feb 27, 2018
@richardlau richardlau mentioned this pull request Jan 9, 2020
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.

3 participants