Snap-installed nodejs fails to install web-ext globally
Is this a feature request or a bug?
Bug
What is the current behavior?
- Installed Node using the official Snap from GNOME software (installation method also recommended by Node on their site)
- Node version confirmed as 14.7.0 and add-ons linter works fine
- Installed web-ext with
sudo npm install --global web-ext - 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
@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, 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"
@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.