reasonml / reason-cli

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

Can't install with npm 5.3.0 #43

Open JimVanEeden opened 7 years ago

JimVanEeden commented 7 years ago

When trying to install with npm install -g https://github.com/reasonml/reason-cli/archive/beta-v-1.13.6-bin-linux.tar.gz, using npm 5.3.0, the installation fails with the following error:

/usr/local/bin/ocamlmerlin -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlmerlin
/usr/local/bin/ocamlmerlin-reason -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlmerlin-reason
/usr/local/bin/ocamlrun -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlrun
/usr/local/bin/ocamlc -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlc
/usr/local/bin/ocamlc.opt -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlc.opt
/usr/local/bin/ocamlopt -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlopt
/usr/local/bin/ocamlopt.opt -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlopt.opt
/usr/local/bin/rtop -> /usr/local/lib/node_modules/reason-cli/.bin/rtop
/usr/local/bin/ocaml -> /usr/local/lib/node_modules/reason-cli/.bin/ocaml
/usr/local/bin/utop -> /usr/local/lib/node_modules/reason-cli/.bin/utop
/usr/local/bin/refmt -> /usr/local/lib/node_modules/reason-cli/.bin/refmt
/usr/local/bin/refmttype -> /usr/local/lib/node_modules/reason-cli/.bin/refmttype
/usr/local/bin/reopt -> /usr/local/lib/node_modules/reason-cli/.bin/reopt
/usr/local/bin/rebuild -> /usr/local/lib/node_modules/reason-cli/.bin/rebuild
/usr/local/bin/reactjs_jsx_ppx -> /usr/local/lib/node_modules/reason-cli/.bin/reactjs_jsx_ppx
/usr/local/bin/reactjs_jsx_ppx_2 -> /usr/local/lib/node_modules/reason-cli/.bin/reactjs_jsx_ppx_2
/usr/local/bin/berror -> /usr/local/lib/node_modules/reason-cli/.bin/berror
/usr/local/bin/menhir -> /usr/local/lib/node_modules/reason-cli/.bin/menhir
/usr/local/bin/ocamlfind -> /usr/local/lib/node_modules/reason-cli/.bin/ocamlfind
/usr/local/bin/reason-cli -> /usr/local/lib/node_modules/reason-cli/.bin/reason-cli

> reason-cli@1.13.6 postinstall /usr/local/lib/node_modules/reason-cli
> ./postinstall.sh

gzip: rel.tar: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reason-cli@1.13.6 postinstall: `./postinstall.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the reason-cli@1.13.6 postinstall 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!     /home/jim/.npm/_logs/2017-07-26T12_10_30_040Z-debug.log

Using my previous npm version (4.1.2), the installation does work. Haven't tried any other versions of npm, just thought you should know this.

adam-bernau commented 7 years ago

I also encountered this issue on Arch linux.

charlesgiroux commented 7 years ago

Same issue on OSX 10.12.6 and npm 5.3.0.

jordwalke commented 7 years ago

Thank you for reporting.

jordwalke commented 7 years ago

I think this is a legitimate issue because I just tried on npmc (their canary). I previously have had no problems with npmc, so something changed with how either npm handles permissions, or how we alter permissions on our releases. Old npm still works well for me, as you've noted.

jordwalke commented 7 years ago

I found that when I do npmc install -g --ignore-scripts reason-cli-url, the resulting directory looks like this:

total 184
drwxr-xr-x  16 me  1876110778   544B Aug 27 23:59 ./
drwxr-xr-x   6 me  1876110778   204B Aug 27 23:59 ../
drwxr-xr-x  22 me  1876110778   748B Aug 27 23:59 .bin/
-rw-r--r--   1 me  1876110778    10B Jul  9 17:55 .npmignore
-rw-r--r--   1 me  1876110778   407B Jul  9 17:55 .travis.yml
-rw-r--r--   1 me  1876110778   1.0K Jul  9 17:55 LICENSE
-rw-r--r--   1 me  1876110778   714B Jul  9 17:55 Makefile
-rw-r--r--   1 me  1876110778   184B Jul  9 17:55 ORIGINS.md
-rw-r--r--   1 me  1876110778   6.6K Jul  9 17:55 README.md
-rw-r--r--   1 me  1876110778   3.3K Aug 27 23:59 package.json
-rw-r--r--   1 me  1876110778    11K Jul  9 17:55 postinstall.sh
-rw-r--r--   1 me  1876110778    11K Jul  9 17:55 prerelease.sh
drwxr-xr-x   5 me  1876110778   170B Aug 27 23:59 records/
-rw-r--r--   1 me  1876110778    33K Jul  9 17:55 rel.tar.gz
drwxr-xr-x   3 me  1876110778   102B Aug 27 23:59 relBinaries/
drwxr-xr-x   4 me  1876110778   136B Aug 27 23:59 releaseUtils/

npmc has removed the executable permissions from postinstall.sh! This might be a bug on their end, or a new security feature. Does anyone know?

jordwalke commented 7 years ago

This issue supposedly says it's fixed, but it still looks broken to me (in the latest canary (5.4 canary 1)).

jordwalke commented 7 years ago

I've filed an issue here on npm's repo. It looks like it's a bug in npm5 :(

andreypopp commented 7 years ago

We can do sh ./postinstall.sh as a workaround?

jordwalke commented 7 years ago

@andreypopp Yes, you should be able to do npmc install -g --ignore-scripts theUrl, and then cd into the npm install location, then chmod 777 postinstall.sh, and then ./postinstall.sh. But if it's the case that npm5 is messing up permissions upon installation, then I would say that npm5 isn't ready for use yet. If it's something we're doing incorrectly, that's another story but so far it looks like a pretty clear cut case of an npm bug.

e41q commented 7 years ago

@jordwalke thanks for answer. It help! A little hint who stucked with that problem too: npm global packages folder can be found by $ npm list -g. For example, at Fedora path is /usr/lib/node_modules/reason-cli/

jordwalke commented 7 years ago

What did you have to do to get it working?

mikowiec commented 7 years ago

Same issue on OSX 10.12.6 , node 8.7.0 and npm 5.4.2

andreypopp commented 7 years ago

@mikowiec do you use nvm or something like that or this was just plain brew install of Node?

mikowiec commented 7 years ago

do you use nvm or something like that or this was just plain brew install of Node?

No, I've installed the latest release node-v8.7.0.pkg from nodejs.org I've make workaround with postinstall.sh and installation finished well. But, the similarly issue occurred when I installed "bs-platform" for testing purposes.

I've uninstalled v8.7 and then installed LTS node-v6.11.4.pkg (where is npm 3.10.10). Then installed "bs-platform" and made the simple project. It was OK for LTS and fault for latest node (npm).

update: brew installed node gave the same issue

adrianmcli commented 6 years ago

My NPM version is 5.5.1 and I still had this issue. Jordan's workaround above worked fine though.

jordwalke commented 6 years ago

@adrianmcli and what is your OS? Are you using the npmc canary? or official npm release?

adrianmcli commented 6 years ago

@jordwalke I was using official npm release 5.5.1 on Mac OS 10.12.6 Sierra. Willing to try other combinations if you'd like.

cirpo commented 6 years ago

Same issue with npm 5.6.0

cirpo commented 6 years ago

As explained in the other opened issue, I fixed it in this way:

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.

countrdd commented 6 years ago

On Mac OSX 10.13 you have to add --unsafe-perm

npm install -g --unsafe-perm electron-icon-generator