reason-cli icon indicating copy to clipboard operation
reason-cli copied to clipboard

Failed to install with npm 5.6.0

Open DarrylD opened this issue 8 years ago • 16 comments

macair:app $ npm --version
5.6.0
macair:app $ npm install -g https://github.com/reasonml/reason-cli/archive/3.0.4-bin-darwin.tar.gz
/usr/local/bin/ocamlmerlin-reason -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlmerlin-reason
/usr/local/bin/refmt -> /usr/local/lib/node_modules/reason-cli/.bin/refmt
/usr/local/bin/reactjs_jsx_ppx_v2 -> /usr/local/lib/node_modules/reason-cli/.bin/reactjs_jsx_ppx_v2
/usr/local/bin/reactjs_jsx_ppx_v3 -> /usr/local/lib/node_modules/reason-cli/.bin/reactjs_jsx_ppx_v3
/usr/local/bin/reason-cli-esy-sandbox -> /usr/local/lib/node_modules/reason-cli/.bin/reason-cli-esy-sandbox
/usr/local/bin/refmttype -> /usr/local/lib/node_modules/reason-cli/.bin/refmttype
/usr/local/bin/utop -> /usr/local/lib/node_modules/reason-cli/.bin/utop
/usr/local/bin/rtop -> /usr/local/lib/node_modules/reason-cli/.bin/rtop
/usr/local/bin/rebuild -> /usr/local/lib/node_modules/reason-cli/.bin/rebuild
/usr/local/bin/reopt -> /usr/local/lib/node_modules/reason-cli/.bin/reopt
/usr/local/bin/ocamlmerlin -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlmerlin

> [email protected] postinstall /usr/local/lib/node_modules/reason-cli
> ./bin/esyBuildRelease bin install

usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `./bin/esyBuildRelease bin install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.¶

DarrylD avatar Dec 23 '17 20:12 DarrylD

👍 same here.

cirpo avatar Dec 28 '17 17:12 cirpo

same issues here. MacOs 10.13.2, npm 5.6 and node 9.2.0.

To fix it, I ran npm install with the --ignore-scripts flag to not execute the faulty post-install script:

npm install -g --ignore-scripts  https://github.com/reasonml/reason-cli/archive/3.0.4-bin-darwin.tar.gz

inside the installation dir .nvm/versions/node/v9.2.0/lib/node_modules/reason-cli/ I had to change the file ownership and group because they were totally wrong:

ll ~/.nvm/versions/node/v9.2.0/lib/node_modules/reason-cli/r/build-eject/bin/esyImportBuild
-rwx------  1 653775386  1876110778  
sudo chown -R $USER r

execute the postinstall script with sudo

sudo ./bin/esyBuildRelease bin install

and everything worked.

It could be that passing --unsafe-perm to the npm install could fix the issue as well but I didn't try it as I already spent 2 hours trying to fix the issue.

cirpo avatar Dec 28 '17 21:12 cirpo

@cirpo Did you try npm install -g with sudo?

Does nvm remove the need to use sudo?

jordwalke avatar Dec 30 '17 00:12 jordwalke

@jordwalke I didn't (I tend to avoid to use sudo as much as I can)

In the next days I will try to replicate different scenarios, I'll keep you posted.

cirpo avatar Dec 30 '17 00:12 cirpo

Thanks, it's pretty common to have to use sudo to install global packages. It's so annoying that I almost always recommend this other approach to avoid ever having to use sudo. I'm trying to tell if this issue you're experiencing is just run of the mill npm sudo issues, vs. something specific to reason-cli.

jordwalke avatar Dec 30 '17 01:12 jordwalke

I used sudo along --unsafe-perm and still have the same issue. Still trying to solve the issue but, I'm not using nvm.

DarrylD avatar Dec 30 '17 20:12 DarrylD

What about sudo without unsafe perm? Can you specify your OS/distro?

jordwalke avatar Dec 30 '17 22:12 jordwalke

I tried all the combinations using nvm node 9.2.0 and npm 5.6 with/without sudo and unsafe-perms: always the same issue.

Tomorrow I will try with the node brew installation without nvm.

On Sat, 30 Dec 2017 at 11:00 pm, Jordan W [email protected] wrote:

What about sudo without unsafe perm? Can you specify your OS/distro?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/reasonml/reason-cli/issues/62#issuecomment-354570766, or mute the thread https://github.com/notifications/unsubscribe-auth/AADING0RoolxbwUjAn0_D1O2bcW8b-heks5tFrJ5gaJpZM4RLwQT .

-- @cirpo

mobile: +44 7492 014 290 skype: cirpolo

linkedin: http://linkedin.com/in/cinellialessandro github: http://github.com/cirpo

cirpo avatar Dec 30 '17 22:12 cirpo

@jordwalke I'm on OS X Yosemite 10.10.5

DarrylD avatar Dec 31 '17 00:12 DarrylD

Just wanted to parrot in here, I'm also on an NVM setup, OS X High Sierra (10.13.2) and exhibited the same problems that @DarrylD and @cirpo had, both sudo and non-sudo.

@jordwalke to answer your question, yes, NVM basically redirects to a "user safe" spot for Node installations, allowing one to switch versions at will and not have to use sudo for global installations.

I tried @cirpo's fix where we drop in --ignore-scripts, change the ownership of r.tar.gz, and then ran sudo ./bin/esyBuildRelease bin install in the reason-cli directory of my globals, and it looks like it worked:

image

ericnograles avatar Dec 31 '17 12:12 ericnograles

cc @andreypopp any clue what this could be (nvm installs should require less permissions than regular npm/node installations I thought)

jordwalke avatar Jan 01 '18 03:01 jordwalke

I tried to repro this but no luck.

My system:

% uname -a
Darwin Andreys-MacBook-Pro.local 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
% node -v
v9.2.0
% npm version
{ npm: '5.6.0',
  ares: '1.13.0',
  cldr: '32.0',
  http_parser: '2.7.0',
  icu: '60.1',
  modules: '59',
  nghttp2: '1.25.0',
  node: '9.2.0',
  openssl: '1.0.2m',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.16.1',
  v8: '6.2.414.44-node.11',
  zlib: '1.2.11' }
% which node
/Users/andreypopp/.nvm/versions/node/v9.2.0/bin/node
% which npm
/Users/andreypopp/.nvm/versions/node/v9.2.0/bin/npm

How did you install nvm? I did:

% curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

To me this sounds like either an npm bug which extract with incorrect permissions in some occasions (I saw something like this on npm bugtracker but they reported those bugs are fixed now) or an incorrect nvm env setup.

andreypopp avatar Jan 02 '18 10:01 andreypopp

Other than all the possibile combinations with nvm, I tried with node 9.3.0, npm 5.6.0 via brew system installation and I get the same "Permission denied" errors.

On Tue, Jan 2, 2018 at 11:19 AM, Andrey Popp [email protected] wrote:

I tried to repro this but no luck.

My system:

% uname -a Darwin Andreys-MacBook-Pro.local 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64 % node -v v9.2.0 % npm version { npm: '5.6.0', ares: '1.13.0', cldr: '32.0', http_parser: '2.7.0', icu: '60.1', modules: '59', nghttp2: '1.25.0', node: '9.2.0', openssl: '1.0.2m', tz: '2017c', unicode: '10.0', uv: '1.16.1', v8: '6.2.414.44-node.11', zlib: '1.2.11' } % which node /Users/andreypopp/.nvm/versions/node/v9.2.0/bin/node % which npm /Users/andreypopp/.nvm/versions/node/v9.2.0/bin/npm

How did you install nvm? I did:

% curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

To me this sounds like either an npm bug which extract with incorrect permissions in some occasions (I saw something like this on npm bugtracker but they reported those bugs are fixed now) or an incorrect nvm env setup.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/reasonml/reason-cli/issues/62#issuecomment-354736254, or mute the thread https://github.com/notifications/unsubscribe-auth/AADINNr0OfxQObDN1wqmmaVPtLSYRdb2ks5tGgKwgaJpZM4RLwQT .

-- @cirpo

mobile: +44 7492 014 290 skype: cirpolo

linkedin: http://linkedin.com/in/cinellialessandro github: http://github.com/cirpo

cirpo avatar Jan 02 '18 10:01 cirpo

There's two different issues going on here it looks like. @DarrylD 's issue is caused by the behaviour of mktemp in Yosemite and earlier, and I've reproduced it on a 10.10 box. More info on the differences and solutions here: https://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x

"Fix" for this is to install with --ignore-scripts, find node_modules/reason-cli, patch r.tar.gz so the files r/build-eject/bin/esyImportBuild and r/build-eject/bin/esyExportBuild use mktemp -d -t 'esytmpdir' in place of mktemp -d and then run ./bin/esyBuildRelease bin install à la @cirpo.

This hack works and solves the problem but I'll look into how we can fix this properly.

4423Q avatar Feb 02 '18 14:02 4423Q

I was having this issue on node v9.5.0 / npm 5.6.0 and debian stretch until I installed gcc/g++, which appears to be required?

hath avatar Feb 03 '18 16:02 hath

@hath Thank you, i was having this error on Linux Mint:

/usr/lib/node_modules/reason-cli/r/build-eject/Makefile:1040: recipe for target '/usr/lib/node_modules/reason-cli/r/build-eject//bin/fastreplacestring.exe' failed

I ran:

sudo apt install build-essential
npm i -g [email protected]

And i'm good now. Docs do mention glibc but i didn't find how to install it, i did with g++.

sbaudray avatar Feb 24 '18 23:02 sbaudray