electron-userland / electron-prebuilt

🎂 Retired project. See README
http://npm.im/electron
MIT License
759 stars 127 forks source link

Postinstall script failing #263

Closed a1626 closed 7 years ago

a1626 commented 7 years ago

In linux/mac machines (not tried on windows) global installation of electron is failing at postinstall script. It is giving EACCES error

/usr/local/bin/electron -> /usr/local/lib/node_modules/electron/cli.js

> electron@1.6.11 postinstall /usr/local/lib/node_modules/electron
> node install.js

/usr/local/lib/node_modules/electron/install.js:47
  throw err
 ^

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@1.6.11 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@1.6.11 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!     /root/.npm/_logs/2017-06-20T10_25_47_997Z-debug.log
a1626 commented 7 years ago

Similar to issue opened in electron.

reblevins commented 7 years ago

A user on the npm repo suggested this: sudo npm install -g electron --unsafe-perm=true --allow-root which worked for me.

a1626 commented 7 years ago

In that case, atleast documentation should be updated to include unsafe-perm flag to install electon globally.

juandfloresm commented 7 years ago

Thanks!

takeknock commented 7 years ago

This is a supplement information. I tried to install Electron on Windows 10 and suffered from a similar problem at postinstall. However, with the tips in this topic, I executed the following and installed Electron successfully. Thanks! npm install -g electron --unsafe-perm=true --allow-root

oktv commented 7 years ago

sorry, I can't install electron package with mentioned option, I run under centos 7

zeke commented 7 years ago

See https://github.com/electron/electron/blob/master/docs/faq.md#why-am-i-having-trouble-installing-electron

fasiha commented 7 years ago

(A thousand apologies for posting this as a comment—I can’t make a new issue because the “Submit new issue” button is disabled for me, and this issue is the closest to my problem.)

I’m trying to npm install electron@1.7.5 on whatever container Glitch.com offers (uname -a says Linux 156ba0fda9dd 4.4.0-83-generic #106-Ubuntu SMP Mon Jun 26 17:54:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux), and it fails here:

$ npm install electron  --unsafe-perm=true
> electron@1.7.5 postinstall /app/node_modules/electron
> node install.js
/app/node_modules/electron/install.js:48
  throw err
  ^
Error: EACCES: permission denied, mkdir '/etc/service/watcher/electron-tmp-download-23212-1502587828401'
    at Error (native)

For some reason, the postinstall is trying to write to /etc but that’s not allowed on this container. Same error with and without --unsafe-perm=true.

Is there any other way (flags, envvar, any configuration) to to ask npm to skip this step of the postinstall? I do not have sudo here and my options are limited.

zeke commented 7 years ago

@fasiha there's a new doc here that should help: https://github.com/electron/electron/blob/master/docs/tutorial/installation.md

fasiha commented 7 years ago

@zeke thanks for pointing that out—I had seen many of these troubleshooting tips in the FAQ you’d linked above, and I was hoping something else could fix this problem, but alas, even with npm install electron --save-dev --save-exact, the postinstall hits Error: EACCES: permission denied, mkdir '/etc/service/watcher/electron-tmp-download-30817-1502589259046'. (And as I mentioned, --unsafe-perm=true has this same error as well.) Any other tips?

I’m really surprised with this—is electron on Linux not installable without sudo? Or is /etc/service/watcher` usually user-writable?

fasiha commented 7 years ago

npm install --ignore-scripts for the win!!! (Via SO, please upvote 👍). Seems to work.

MarshallOfSound commented 7 years ago

@fasiha Urgh, --ignore-scripts will be successful, but it won't actually install electron 😕

Like, if you ignore the scripts it won't try and download Electron. The issue here is your OS's temp directory does not appear to be writable by your user. You should fix that before anything else 👍

kgryte commented 7 years ago

@MarshallOfSound Seems a bit odd that the temp directory is in /etc. That does not follow FHS.

MarshallOfSound commented 7 years ago

@kgryte It's whatever require('os').tmpdir() outputs I beleive

kgryte commented 7 years ago

@MarshallOfSound Yes, but that is not what is being used (at least from what I can gather). If we follow the logic

https://github.com/electron-userland/electron-prebuilt/blob/e5fe0fb379b94fe8b1ea2d9b8452d9413f7ca609/install.js#L26 https://github.com/electron-userland/electron-download/blob/0c964902f110df1587d925ae26c550f4b9786957/lib/index.js#L189 https://github.com/electron-userland/electron-download/blob/0c964902f110df1587d925ae26c550f4b9786957/lib/index.js#L54 https://github.com/sindresorhus/env-paths/blob/e61ddbde6c89222f1b7a1f8b941a2d8ff2d60527/index.js

The process looks to be trying to create a directory for caching downloads. On @fasiha's system, for whatever reason, that logic seems to be failing.

FWIW and as an aside, periodically when I install electron on various build systems (e.g., Travis CI, Circle CI, and AppVeyor), I encounter EACCES errors, as well. I have never investigated the reasons for the periodic failures. I usually just restart my build jobs and the problem usually disappears.

MarshallOfSound commented 7 years ago

@kgryte Probably means he has XDG_CACHE_HOME set to something weird

fasiha commented 7 years ago

@MarshallOfSound @kgryte thank you for your help, thank to the XDG_CACHE_HOME hint, I found this!!!

$ export  | grep etc
# ... snip ...
declare -x TMPDIR="/etc/service/watcher"

How strange! This might be because Glitch.com treats /tmp as part of the backed up filesystem and doesn’t want apps/modules to using $TMPDIR for actual junk. I will notify them of this weirdness.

Janatbek commented 7 years ago

@fasiha can you explain what is this? npm install --ignore-scripts

fasiha commented 7 years ago

@Janatbek “The --ignore-scripts argument will cause npm to not execute any scripts defined in the package.json. See npm-scripts.” (via https://docs.npmjs.com/cli/install)

RomanHargrave commented 6 years ago

Observed in the wild, occurred when run as root.

alkismavridis commented 6 years ago

A user on the npm repo suggested this: sudo npm install -g electron --unsafe-perm=true --allow-root which worked for me.

reblevins, this worked for me too. You saved my day. Thanks a lot!

P0oOOOo0YA commented 6 years ago

Still an issue on 3.05, the same issue i had on 2.05.

$ sudo npm install electron -g
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js

> electron@3.0.5 postinstall /usr/lib/node_modules/electron
> node install.js

/usr/lib/node_modules/electron/install.js:49
  throw err
  ^

Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@3.0.5 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@3.0.5 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

$ uname -r
4.18.0-kali1-amd64