chrisa / node-dtrace-provider

Native DTrace probes for node.js apps
Other
320 stars 68 forks source link

install.js tries to rename a non existing file #105

Open dereckson opened 6 years ago

dereckson commented 6 years ago

On FreeBSD 11, the install.js script tries to rename a file not yet existing:

$ npm install -g dtrace-provider
>  dtrace-provider@0.8.5 install /usr/local/lib/node_modules/dtrace-provider
> node scripts/install.js

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

Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/dtrace-provider/compile.py' -> '/usr/local/lib/node_modules/dtrace-provider/binding.gyp'
    at Object.fs.renameSync (fs.js:768:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/dtrace-provider/scripts/install.js:14:4)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
    at Function.Module.runMain (module.js:653:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

$ ls /usr/local/lib/node_modules/dtrace-provider
ls: /usr/local/lib/node_modules/dtrace-provider: No such file or directory

This issue only occurs with -g: it can install in node_modules/ without any issue.

AndrewTasso commented 6 years ago

I'm also running into the same issue on MacOS Sierra

$ sudo npm install -g dtrace-provider

> dtrace-provider@0.8.5 install /usr/local/lib/node_modules/dtrace-provider
> node scripts/install.js

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

Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/dtrace-provider/compile.py' -> '/usr/local/lib/node_modules/dtrace-provider/binding.gyp'
    at Object.fs.renameSync (fs.js:766:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/dtrace-provider/scripts/install.js:14:4)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dtrace-provider@0.8.5 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the dtrace-provider@0.8.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Andrew/.npm/_logs/2017-12-12T18_34_50_863Z-debug.log
melloc commented 6 years ago

This looks like the same problem as #110, and seems to be related to how npm drops permissions. I've reworked how the install lifecycle script gets run to hopefully recover from this kind of failure better. If you've continued having the issue, could you please try again and see if it still fails with dtrace-provider@0.8.6? You may want to run it with V set in the environment so we can see where it fails. For example:

$ V=1 sudo npm install -g dtrace-provider

It's possible that the only way to get the lifecycle scripts to run safely when doing a global install as root is with --unsafe-perm, so you may want to consider using that.