git-validate icon indicating copy to clipboard operation
git-validate copied to clipboard

Install fails as root

Open kerrick-lyft opened this issue 8 years ago • 1 comments

When git-validate is installed as a dependency of another package when running npm install as root, git-validate fails to install.

The specific error is:

fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EACCES: permission denied, open '/tmp/baz/openstreetmap/.git/hooks/pre-commit'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.writeFileSync (fs.js:1333:33)
    at Object.exports.installHooks (/tmp/baz/openstreetmap/node_modules/git-validate/lib/utils.js:248:12)
    at Object.<anonymous> (/tmp/baz/openstreetmap/node_modules/git-validate/bin/install.js:3:7)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

This does not happen if I run as a regular user, or if I directly git clone this repo and run npm install.

To reproduce this, you can run the following (as root):

git clone https://github.com/pelias/openstreetmap.git && cd openstreetmap && npm install

P.S. I noticed that /tmp/baz/openstreetmap/.git/hooks/pre-commit does not exist. If I touch it, I get a different error:

fs.js:809
  return binding.rename(pathModule._makeLong(oldPath),
                 ^

Error: EACCES: permission denied, rename '/tmp/baz/openstreetmap/.git/hooks/pre-commit' -> '/tmp/baz/openstreetmap/.git/hooks/pre-commit.backup'
    at Error (native)
    at Object.fs.renameSync (fs.js:809:18)
    at Object.exports.installHooks (/tmp/baz/openstreetmap/node_modules/git-validate/lib/utils.js:245:16)
    at Object.<anonymous> (/tmp/baz/openstreetmap/node_modules/git-validate/bin/install.js:3:7)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
[email protected] /tmp/baz/openstreetmap

kerrick-lyft avatar Dec 13 '17 02:12 kerrick-lyft

~~We detected this as well for pre-push hooks - https://github.com/ipfs/aegir/issues/251. Actually, slight different, the issue that we see is that it doesn't find the file.~~

Diagnosis of this one is still incomplete. I can't reproduce it 100% of the times anymore.

daviddias avatar Jul 13 '18 08:07 daviddias