reasonml / reason-cli

Globally installable Reason toolchain.
MIT License
291 stars 23 forks source link

Failed to install with npm 5.6.0 #62

Open DarrylD opened 6 years ago

DarrylD commented 6 years ago
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

> reason-cli@3.0.4 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! reason-cli@3.0.4 postinstall: `./bin/esyBuildRelease bin install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reason-cli@3.0.4 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.¶
cirpo commented 6 years ago

👍 same here.

cirpo commented 6 years ago

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.

jordwalke commented 6 years ago

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

Does nvm remove the need to use sudo?

cirpo commented 6 years ago

@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.

jordwalke commented 6 years ago

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.

DarrylD commented 6 years ago

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

jordwalke commented 6 years ago

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

cirpo commented 6 years ago

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 notifications@github.com 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

DarrylD commented 6 years ago

@jordwalke I'm on OS X Yosemite 10.10.5

ericnograles commented 6 years ago

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

jordwalke commented 6 years ago

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

andreypopp commented 6 years ago

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.

cirpo commented 6 years ago

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 notifications@github.com 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

4423Q commented 6 years ago

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.

hath commented 6 years ago

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?

sbaudray commented 6 years ago

@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 reason-cli@3.1.0-linux

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