-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
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.
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) |
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.
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.
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 my guard statements on one line, mainly for greppability.
I added a test that skirts around doing actual I/O, PTAL. |
} | ||
|
||
gyp.commands.install([], function (err) { | ||
t.ok(true) |
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.
Could this test be removed and the test count reduced to 2?
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.
Well, you want to know that the final callback is called, right? Or do I misunderstand you?
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.
Fair point.
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]>
Retry the download+install dance only once after encountering an EACCES.
That only happens when both the devdir (usually:
$HOME/.node-gyp
) andthe current working directory aren't writable. Users won't often hit
that except through
sudo npm install
because npm drops privilegesbefore executing node-gyp.
Fixes #1383.