Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Nativefier 8.0.0-8.0.3 fails to sudo-globally-install, with permission error in postinstall script #923

Closed
BananaManCJ opened this issue Mar 16, 2020 · 29 comments
Labels

Comments

@BananaManCJ
Copy link

BananaManCJ commented Mar 16, 2020

EDIT from maintainer @ronjouch: see #923 (comment) for details. I'm working on a fix (probably reverting to webpacking the placeholder app at build time, see #898 (comment)). Until then, you should:

  • stay with 7.7.1...
  • or install nativefier non-globally (npm install nativefier, then invoke it with node ./node_modules/.bin/nativefier <your-options-here>)...
  • or set your npm_config_prefix to somewhere user-writable and npm install -g nativefier without sudo.

I am trying to install Nativefier and it keeps failing. I am on Lubuntu 19.10, have the latest verison of nodejs and npm.

Error in terminal:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nativefier@8.0.2 postinstall: `cd app && yarn install --no-lockfile --no-progress --silent`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the nativefier@8.0.2 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/2020-03-15T23_58_29_502Z-debug.log

Log:
2020-03-15T23_58_29_502Z-debug.log

@ronjouch ronjouch changed the title Nativefier install fail Nativefier 8.0.2 fails to install Mar 16, 2020
@ronjouch ronjouch added the bug label Mar 16, 2020
@ronjouch
Copy link
Contributor

@BananaManCJ thanks. Confirmed at #719 (comment) . Looking, all help / ideas / additional debug info welcome.

@raulcraveiro
Copy link

raulcraveiro commented Mar 16, 2020

I'm having the same problem with Ubuntu 19.10 Gnome.

Maybe is something specific with Ubuntu? 🤔

@ronjouch ronjouch pinned this issue Mar 16, 2020
@BananaManCJ
Copy link
Author

I can check to see if this is a Ubuntu-specific issue, I have a Mac

@ronjouch ronjouch changed the title Nativefier 8.0.2 fails to install Nativefier 8.0.2 fails to install, with error in postinstall script Mar 16, 2020
@ronjouch
Copy link
Contributor

I can check to see if this is a Ubuntu-specific issue, I have a Mac

@BananaManCJ yes please, on my side looking on a Windows machine. Thanks 🙏.

@BananaManCJ
Copy link
Author

Can confirm that the error occurs on MacOS

@BananaManCJ
Copy link
Author

It outputs more information on MacOS

Output:
warning Skipping preferred cache folder "/Users/rosefam/Library/Caches/Yarn" because it is not writable.
warning Skipping preferred cache folder "/usr/local/lib/node_modules/nativefier/.yarn-cache-4294967294" because it is not writable.
warning Skipping preferred cache folder "/usr/local/lib/node_modules/nativefier/.yarn-cache" because it is not writable.
error Yarn hasn't been able to find a cache folder it can use. Please use the explicit --cache-folder option to tell it what location to use, or make one of the preferred locations writable.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nativefier@8.0.2 postinstall: cd app && yarn install --no-lockfile --no-progress --silent
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nativefier@8.0.2 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! /Users/rosefam/.npm/_logs/2020-03-16T00_20_23_351Z-debug.log

@ronjouch
Copy link
Contributor

On my side,

  • No problem on Windows.
  • Haven't tried global installing on Arch, I don't want to pollute my system.
  • Under docker image ubuntu:19:10, I get another issue with yarn, but I'm not sure it's the same thing, given this is not a regular environment:
> nativefier@8.0.2 postinstall /usr/local/lib/node_modules/nativefier
> cd app && yarn install --no-lockfile --no-progress --silent

Error: EACCES: permission denied, open '/root/.config/yarn'
    at Object.openSync (fs.js:439:3)
    at readFileSync (fs.js:344:35)
    at /usr/local/lib/node_modules/nativefier/node_modules/yarn/lib/cli.js:101331:58
    at Array.map (<anonymous>)
    at parseRcPaths (/usr/local/lib/node_modules/nativefier/node_modules/yarn/lib/cli.js:101329:78)
    at Object.findRc (/usr/local/lib/node_modules/nativefier/node_modules/yarn/lib/cli.js:101343:10)
    at getRcConfigForCwd (/usr/local/lib/node_modules/nativefier/node_modules/yarn/lib/cli.js:56915:74)
    at /usr/local/lib/node_modules/nativefier/node_modules/yarn/lib/cli.js:92694:56
    at Generator.next (<anonymous>)
    at step (/usr/local/lib/node_modules/nativefier/node_modules/yarn/lib/cli.js:310:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nativefier@8.0.2 postinstall: `cd app && yarn install --no-lockfile --no-progress --silent`

Using yarn to bundle the electron app was added with 8.x, after long discussion summed up at #898 (comment) . Trying to see if we can make this work, of considering coming back to Webpacking the app 😕.

@raulcraveiro
Copy link

It shows this yarn error here too.

I'm installing Fedora 31 here, and I'll try again...

@ronjouch
Copy link
Contributor

@raulcraveiro @BananaManCJ can you try installing with environment variable YARN_CACHE_FOLDER set to /tmp? So, sudo YARN_CACHE_FOLDER=/tmp npm install -g nativefier

@raulcraveiro
Copy link

Just tried, got the same error :/ @ronjouch

@BananaManCJ
Copy link
Author

On Linux or MacOS @ronjouch

@ronjouch
Copy link
Contributor

On Linux or MacOS @ronjouch

@BananaManCJ both welcome. Thanks 🙂.

@BananaManCJ
Copy link
Author

BananaManCJ commented Mar 16, 2020

WOAH, got a bigger error message this time
https://pastebin.com/FaHdP602

@ronjouch
Copy link
Contributor

@BananaManCJ yeah, samed as the one I got in a Docker:

Error: EACCES: permission denied, open '/root/.config/yarn'
    at Object.openSync (fs.js:439:3)
    at readFileSync (fs.js:344:35)
    at /home/rosefam/nativefier/node_modules/yarn/lib/cli.js:101331:58
    at Array.map (<anonymous>)
    at parseRcPaths (/home/rosefam/nativefier/node_modules/yarn/lib/cli.js:101329:78)
    at Object.findRc (/home/rosefam/nativefier/node_modules/yarn/lib/cli.js:101343:10)
    at getRcConfigForCwd (/home/rosefam/nativefier/node_modules/yarn/lib/cli.js:56915:74)
    at /home/rosefam/nativefier/node_modules/yarn/lib/cli.js:92694:56
    at Generator.next (<anonymous>)
    at step (/home/rosefam/nativefier/node_modules/yarn/lib/cli.js:310:30)

@BananaManCJ
Copy link
Author

I don't see a /root/.config/yarn folder on my system, am I missing a dependency?

@ronjouch
Copy link
Contributor

I don't see a /root/.config/yarn folder on my system, am I missing a dependency?

@BananaManCJ nope, you're good, the problem is on yarn, not you. I'm preparing a workaround, keeping you posted.

@raulcraveiro
Copy link

Just tried on Fedora 31, getting the same error :/

@ronjouch
Copy link
Contributor

ronjouch commented Mar 16, 2020

@BananaManCJ @raulcraveiro I published a workaround, can you give it a try? npm install -g nativefier@8.0.3

The workaround will introduce a 60s delay at installation time, but give it time and it should finish. Waiting for your feedback.

EDIT gaaaah, maybe not actually, I get this error in my Ubuntu 19.10 Docker. Well, give it a try anyway if you have the time, maybe it works for you.

glob error { [Error: EACCES: permission denied, scandir '/root/.npm/_logs']
  stack:
   'Error: EACCES: permission denied, scandir \'/root/.npm/_logs\'',
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs' }

@raulcraveiro
Copy link

raulcraveiro commented Mar 16, 2020

@ronjouch

I got this error:

`
npm WARN deprecated request@2.88.2: request has been deprecated, see request/request#3142
npm WARN checkPermissions Missing write access to /usr/local/lib
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib'] {
npm ERR! stack: "Error: EACCES: permission denied, access '/usr/local/lib'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/raul/.npm/_logs/2020-03-16T01_19_44_911Z-debug.log
`

@BananaManCJ
Copy link
Author

@ronjouch I get the same error, I think @raulcraveiro forgot to run npm as root

@BananaManCJ
Copy link
Author

BananaManCJ commented Mar 16, 2020

I also tried running sudo npm install -g nativefier@8.0.1 and got the same error as 8.0.2

Edit: also in 8.0.0

@ronjouch
Copy link
Contributor

ronjouch commented Mar 16, 2020

Okay yes, still broken. My understanding so far:

  • This issue is caused by installing placeholder app dependencies at nativefier install time, with yarn (8.0.2) or npm (8.0.3). This is new in Nativefier 8.x, for the motivations behind it, see Revamp and move to TypeScript #898 (comment) .
  • During testing, I did test global installs, but never to a system / non-user-writable path (my $npm_config_prefix is set to "$HOME/.node_modules")
  • But without such a config and when installing globally to a non-user-writable/system path with sudo npm i -g nativefier,
    • Installation of nativefier core works...
    • ... but then postinstall tries to do its job of installing app deps, and fails in various OS-dependent ways, but all about access rights.
      I suspect that, although main nativefier install runs as su with access rights to system paths, postinstall scripts are run out of su. That would make sense for security reasons: out of hook scripts, npm knows exactly what will be touched in your filesystem: it's the static contents of the published tarball; a postinstall script with sudo rights could do nasty dynamic stuff. So, although I don't see any mention of that in npm-scripts docs / hooks and I haven't dug npm/cli's code, I can understand it.

So, I'm going to sleep on that, and next week I'll revert back to webpacking the placeholder app (or do something else if I/someone has a better idea). Until then, stay with 7.7.1 or install non-globally 🙂. I'm adding this blurb to the issue description, and mentioned the issue in the 8.0.3 release description.

Thanks for the feedback everybody!

@BananaManCJ
Copy link
Author

No problem!

@ronjouch ronjouch changed the title Nativefier 8.0.2 fails to install, with error in postinstall script Nativefier 8.0.2 fails to sudo-globally-install, with error in postinstall script Mar 16, 2020
@raulcraveiro
Copy link

Thank you for the attention! If you need any help testing on Ubuntu, I can help ;)

@ronjouch ronjouch changed the title Nativefier 8.0.2 fails to sudo-globally-install, with error in postinstall script Nativefier 8.0.2 fails to sudo-globally-install, with permission error in postinstall script Mar 16, 2020
@BananaManCJ BananaManCJ changed the title Nativefier 8.0.2 fails to sudo-globally-install, with permission error in postinstall script Nativefier 8.0.0-8.0.3 fails to sudo-globally-install, with permission error in postinstall script Mar 16, 2020
@remissao
Copy link

Getting the same issue in macOS with ohmyzsh.

Here's the log file:
2020-03-16T11_57_04_480Z-debug.log

@ronjouch
Copy link
Contributor

@BananaManCJ @raulcraveiro @remissao @cwensel issue should be fixed in Nativefier 8.0.4 just published on npm! Confirmed working in my Ubuntu 19.10 docker. Please npm install -g nativefier@8.0.4 and confirm 🙂.

@raulcraveiro
Copy link

It worked! Thank you so much ;)

@ronjouch
Copy link
Contributor

It worked! Thank you so much ;)

@raulcraveiro yayyyyy welcome 🙂. Thank you and thanks everyone here for the feedback!

@ronjouch ronjouch unpinned this issue Mar 17, 2020
@GraceYane
Copy link

D:\Desktop\native>npm install nativefier -g
npm ERR! code EPERM
npm ERR! syscall copyfile
npm ERR! path D:\vueTemp\node\node_global\node_modules\nativefier\node_modules\lodash\startsWith.js
npm ERR! dest D:\vueTemp\node\node_global\node_modules.nativefier-MDa3moWJ\node_modules\lodash\startsWith.js
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, copyfile 'D:\vueTemp\node\node_global\node_modules\nativefier\node_modules\lodash\startsWith.js' -> 'D:\vueTemp\node\node_global\node_modules.nativefier-MDa3moWJ\node_modules\lodash\startsWith.js'
npm ERR! [Error: EPERM: operation not permitted, copyfile 'D:\vueTemp\node\node_global\node_modules\nativefier\node_modules\lodash\startsWith.js' -> 'D:\vueTemp\node\node_global\node_modules.nativefier-MDa3moWJ\node_modules\lodash\startsWith.js'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'copyfile',
npm ERR! path: 'D:\vueTemp\node\node_global\node_modules\nativefier\node_modules\lodash\startsWith.js',
npm ERR! dest: 'D:\vueTemp\node\node_global\node_modules\.nativefier-MDa3moWJ\node_modules\lodash\startsWith.js'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! D:\vueTemp\node\node_cache_logs\2022-08-04T09_26_16_287Z-debug-0.log

D:\Desktop\native>

This is why??

Adam777Z pushed a commit to Adam777Z/nativefier that referenced this issue Nov 9, 2022
…ivefier#923)

As documented in nativefier#923 (comment) ,

- nativefier#923 is caused by installing placeholder app deps at nativefier
  *install* time, with yarn (8.0.2) or npm (8.0.3). This is new in
  Nativefier 8.x, for the motivations behind it, see
  nativefier#898 (comment)

- During testing, I did test global installs, but never to a
  system / non-user-writable path (my `$npm_config_prefix` is set to
  `"$HOME/.node_modules"`)

- But without such a config and when installing globally to a
  non-user-writable/system path with `sudo npm i -g nativefier`,

    - Installation of nativefier core works...

    - ... but then `postinstall` tries to do its job of installing
    app deps, and fails in various OS-dependent ways, but all about
    access rights.
    I suspect that, although main nativefier install runs as `su` with
    access rights to system paths, `postinstall` scripts are run *out*
    of `su`.
    That would make sense for security reasons: out of hook scripts,
    npm knows exactly what will be touched in your filesystem: it's the
    static contents of the published tarball; a postinstall script with
    sudo rights could do nasty dynamic stuff. So, although I don't see
    any mention of that in
    [npm-scripts docs / hooks](https://docs.npmjs.com/misc/scripts#hook-scripts)
    and I haven't dug npm/cli's code, I can understand it.

So, reverting back to `webpack`ing the placeholder app, as done pre-8.0.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants