-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
EISDIR error when invoked from cacache under sudo to fix ownership on MacOS #20
Comments
PS: node v10 removed the in my eyes dubious implementation of lchown/lchmod on MacOS and replaced it with a libuv-based implementation. @snoack pointed out potential problems with this implementation as early as 2014, although the masses didn't get bitten by it in such large numbers until a631d84 landed which started using The decision to use lchown where available, including MacOS, as part of the response to #14 is what is adversely affecting the users of node v8.x on MacOS. A possible fix might be to use lchown only if node version >= 10.6, which is when libuv based lchown landed and the MacOS specific buggy implementation was removed. |
See also issue 8203 in which a Mac user confirms my speculations. |
Landed in chownr 1.1.2. I'll update the dep in npm/cli for the next release. |
This handles an EISDIR error from cacache on Darwin in Node versions prior to 10.6. Fix: [npm.community#7901](https://npm.community/t/7901/) Fix: [npm.community#8203](https://npm.community/t/8203/) Fix: isaacs/chownr#20 PR-URL: isaacs/chownr#21
The npm.community site is dealing with a frequent failure mode whereby
sudo npm install -g ...
results in anEISDIR
error on such paths as/Users/xxx/.npm/_cacache/index-v5/77/b2
. They call it the EISDIR conundrum.Thanks to one of the users on that site we were able to pinpoint this error and tracked it to where
cacache
invokes thechownr
function to fix up the ownership of the directory it just created. I believe that npm 6.9.0 useschownr
1.1.1, which would indicate that this code somehow ends up returningEISDIR
via a callback to the caller (this is then turned via BB to the rejected promise visible in the error log.Taken literally, the error would mean that
chownr
invokes theopen(2)
system call on the directory it is given on some execution path. The only path I could see that (on MacOS, whereO_SYMLINK
is defined) would be vialchown
which has this implementation in node v8.x:I do not understand why this function calls
fs.open()
unconditionally. If the file in question is not a symlink, wouldn't this guarantee anEISDIR
? According to the OpenGroup,lchown
should behave likechown
unless the object in question is a symbolic link. The code in question appears to work if and only if the object in question is a symbolic link.Side note:
chownr
prior to v1.1.1 usedchown
, which does not perform thisopen
call. I believe that the use oflchown
was introduced by commit a631d84 which is included in v1.1.1 which ships in npm 6.9.0 as per package.jsonI'll stop here. I realize from what I've written so far that if my interpretation is correct, this is a node.js bug (MacOS specific) and not a chownr bug, but I'll leave this here for future reference anyway.
The text was updated successfully, but these errors were encountered: