avh4 / binwrap

Distribute binaries via npm
39 stars 17 forks source link

Running from packages that need to be installed globally, it didn't check root permissions. #8

Open reinaldorauch opened 6 years ago

reinaldorauch commented 6 years ago

When I was installing elm-format globally, which depends on binwrap to install, it crashes with permssions error:

output:

/usr/bin/elm-format -> /usr/lib/node_modules/elm-format/bin/elm-format

> elm-format@0.6.1-alpha install /usr/lib/node_modules/elm-format
> binwrap-install

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

Error: EACCES: permission denied, open 'bin/elm-format'
    at Object.fs.openSync (fs.js:653:18)
    at Object.fs.writeFileSync (fs.js:1300:33)
    at /usr/lib/node_modules/elm-format/node_modules/binwrap/install.js:17:8
    at Array.forEach (<anonymous>)
    at install (/usr/lib/node_modules/elm-format/node_modules/binwrap/install.js:15:19)
    at Object.install (/usr/lib/node_modules/elm-format/node_modules/binwrap/index.js:8:14)
    at Object.<anonymous> (/usr/lib/node_modules/elm-format/node_modules/binwrap/bin/binwrap-install:16:9)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:201:16)
    at bootstrap_node.js:626:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elm-format@0.6.1-alpha install: `binwrap-install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elm-format@0.6.1-alpha install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm-install-error.log.txt

sebn commented 6 years ago

Same issue here. Fedora 27, tried both node 8.9.3 (default) and 8.9.4 (nodesource). With and without sudo.

sebn commented 6 years ago

Workaround:

sudo npm install -g elm-format --ignore-scripts
cd /usr/lib/node_modules/elm-format/
sudo rm bin/elm-format
sudo npm run install
sebn commented 6 years ago

Better workaround:

$ npm config get -g user
nobody
$ sudo npm config set -g user root
$ sudo npm install -g elm-format
...
+ elm-format@0.6.1-alpha
added 93 packages in 50.2s

Looks like an npm setup issue, not a binwrap one, at least for me... @reinaldorauch Could you check on your side?

reinaldorauch commented 6 years ago

Sorry for the late reply, will test on my coding machine and return to you

avh4 commented 5 years ago

Have we been able to figure out if there's something binwrap could be doing differently that would avoid this problem (or give a better error message if it's not avoidable)?

reinaldorauch commented 5 years ago

@sebn the workaround worked, many thanks

@avh4 I will try to figure it out.