web-ext icon indicating copy to clipboard operation
web-ext copied to clipboard

Snap-installed nodejs fails to install web-ext globally

Open plwt opened this issue 4 years ago • 3 comments

Is this a feature request or a bug?

Bug

What is the current behavior?

  1. Installed Node using the official Snap from GNOME software (installation method also recommended by Node on their site)
  2. Node version confirmed as 14.7.0 and add-ons linter works fine
  3. Installed web-ext with sudo npm install --global web-ext
  4. Install fails with error Failed at the [email protected] postinstall script. Full log attached at 2021-06-14T20_15_57_535Z-debug.log

What is the expected or desired behavior?

web-ext installs without error

Version information (for bug reports)

  • Firefox version: 91.0a1
  • Your OS and version: Xubuntu 21.04
  • Paste the output of these commands:
node --version && npm --version && web-ext --version

v14.17.0 6.14.13 web-ext: command not found

plwt avatar Jun 14 '21 20:06 plwt

@SeburoSUMO I'm currently unable to reproduce this using the snap package installed on Ubuntu 20.04.2 (web-ext was installed globally just fine and the core-js message was printed on the console.

Based on the stack trace I would guess that on your system it did fail to execute the node binary while executing node -e "try{require('./postinstall')}catch(e){}" for the core-js postinstall script.

I'm going to give it another try on an ubuntu 21.04 installation (in a virtual machine) as soon as I can, but in the meantime would you mind to double-check if /snap/bin is actually part of the $PATH for the root user on your system?

At the moment, the only thing that I can think of that could trigger that issue is the root user not having /snap/bin in the PATH environment variable (which honestly it seems unlikely, but may be worth to still double-check if that is the case).

rpl avatar Jun 16 '21 12:06 rpl

@rpl, it does appear that /snap/bin is the PATH. The contents of /etc/environment is:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

plwt avatar Jun 16 '21 21:06 plwt

@SeburoSUMO I've been able to reproduce it on a vanilla Xubuntu 21.04 system installed in a VM.

The issue seems to be due to snap confinement (even if technically this snap package has to be installed using snap --classic) it looks that there are some apparmor based restrictions which are triggering the issue.

I did find the following issues (and one pull request in the snapd repo) related to the issue with snap-packaged nodejs:

  • zloirock/core-js#915
  • nodejs/node#37982
  • snapcore/snapd#10029
  • https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753

There is also a workaround that make the snap-packaged nodejs to work just fine, the details are described in this nodejs doc page: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory.

In practice the workaround prevents the issue because it does configure npm to put the global installed packages into a directory where the user does have read-write permissions and no apparmor rule would block the npm installation to complete successfully.

rpl avatar Jun 22 '21 14:06 rpl