elm-lang / elm-platform

Bundle of all core development tools for Elm
BSD 3-Clause "New" or "Revised" License
762 stars 125 forks source link

Fail of npm install -g elm on linux systems. #236

Open eprparadocs opened 6 years ago

eprparadocs commented 6 years ago

I get a failure when using npm install on my linux system. I get the ELIFECYCLE error. I've retried it on two different linux systems with the same outcome.

cornjuliox commented 6 years ago

I'm not able to install as well, using sudo npm install -g elm

 [34] → sudo npm install -g elm
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/usr/bin/elm -> /usr/lib/node_modules/elm/binwrappers/elm
/usr/bin/elm-make -> /usr/lib/node_modules/elm/binwrappers/elm-make
/usr/bin/elm-package -> /usr/lib/node_modules/elm/binwrappers/elm-package
/usr/bin/elm-repl -> /usr/lib/node_modules/elm/binwrappers/elm-repl
/usr/bin/elm-reactor -> /usr/lib/node_modules/elm/binwrappers/elm-reactor

> elm@0.18.0 install /usr/lib/node_modules/elm
> node install.js

Error extracting linux-x64.tar.gz - Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/elm/Elm-Platform'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elm@0.18.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elm@0.18.0 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!     /home/me/.npm/_logs/2018-05-05T16_04_25_674Z-debug.log

On Ubuntu 16.04. edit: also using npm 6.0.0 node 8.11.1

cornjuliox commented 6 years ago

Changing the default npm directory as listed here (https://docs.npmjs.com/getting-started/fixing-npm-permissions) and trying again gets me an ELIFECYCLE error

[74] → npm install -g elm
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/home/enricojr/.npm-global/bin/elm -> /home/enricojr/.npm-global/lib/node_modules/elm/binwrappers/elm
/home/enricojr/.npm-global/bin/elm-make -> /home/enricojr/.npm-global/lib/node_modules/elm/binwrappers/elm-make
/home/enricojr/.npm-global/bin/elm-package -> /home/enricojr/.npm-global/lib/node_modules/elm/binwrappers/elm-package
/home/enricojr/.npm-global/bin/elm-reactor -> /home/enricojr/.npm-global/lib/node_modules/elm/binwrappers/elm-reactor
/home/enricojr/.npm-global/bin/elm-repl -> /home/enricojr/.npm-global/lib/node_modules/elm/binwrappers/elm-repl

> elm@0.18.0 install /home/enricojr/.npm-global/lib/node_modules/elm
> node install.js

Downloading Elm binaries from https://dl.bintray.com/elmlang/elm-platform/0.18.0/linux-x64.tar.gz
Error decompressing linux-x64.tar.gz Error: unexpected end of file
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elm@0.18.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elm@0.18.0 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!     /home/enricojr/.npm/_logs/2018-05-06T09_35_42_628Z-debug.log

Strangely , it seems to have installed properly anyways. ~/.npm-global has contents in it, elm and elm-package seem to work from the command line, and which elm / which elm-package both return /home/enricojr/.npm_global/bin/ as a result.

I'm not entirely sure what's happened.

mkohler commented 6 years ago

I'm not an npm expert, but I think many of these problems may be related to file permissions.

On Linux systems, by default "npm install -g <package" will try to install packages under /usr/local. That requires root privileges, aka sudo, and is rarely what you want. On Linux systems, the /usr/local area is for packages that you have built yourself, and are installing for all users.

Instead, what you probably want, is to create a directory under your home directory, where you install npm tools that you want to use across many projects. As cornjuliox notes, detailed instructions for how to do that are here: https://docs.npmjs.com/getting-started/fixing-npm-permissions

I just created a pull request to add a link to that document to the installation instructions.

palutz commented 6 years ago

Same problem with Ubuntu 18.04

heyakyra commented 6 years ago

If this is what I think:

225 to track the elm bug

226 for the workaround

VinceMacBuche commented 6 years ago

I have the same issue even when running the install command with sudo, even running it as root ...

This happens to me on Fedora 28, with node 8.11.3 and npm 5.6.0

here a gist of the npm debug log: https://gist.github.com/VinceMacBuche/f1baf62388755167ea5c32c1258fce5c

Maybe a change in Node 8.11 ? (released in March ...)

VinceMacBuche commented 6 years ago

I finally manage to install it using

sudo npm install -g elm --unsafe-perm=true --allow-root

I remembered that it was an option that could be necessary for elm-github-install so i tried with elm, i guess some perms / file owner are not corresponding to Node/npm standard ...

Note that i found that this issue is quite common among other libs (found several links about a lifecycle issue) that were few month old ( From March to May) all about Node 8.11