Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm execs node-gyp as SUDO_USER not as USER. #1275

Closed
jessegranger opened this issue May 12, 2020 · 1 comment
Closed

[BUG] npm execs node-gyp as SUDO_USER not as USER. #1275

jessegranger opened this issue May 12, 2020 · 1 comment
Labels
Bug thing that needs fixing

Comments

@jessegranger
Copy link

What / Why

If you run sudo npm install, any modules that require to be built with node-gyp will attempt that build as the wrong user ($SUDO_USER).

When

  • sudo npm install heapdump (or any module that needs node-gyp)

How

Current Behavior

  • sudo npm install heapdump
  • Result:

> [email protected] install /opt/mpath/api/node_modules/heapdump
> node-gyp rebuild

gyp WARN EACCES current user ("jesse") does not have permission to access the dev dir "/root/.cache/node-gyp/14.2.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/opt/mpath/api/node_modules/heapdump/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/opt/mpath/api/node_modules/heapdump/.node-gyp'
gyp ERR! System Linux 3.10.0-1062.18.1.el7.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /opt/mpath/api/node_modules/heapdump
gyp ERR! node -v v14.2.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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!     /root/.npm/_logs/2020-05-12T13_40_57_692Z-debug.log

Key Facts:

The command is running under sudo, and the current $SUDO_USER is jesse, but according to the node-gyp team, this is a correct error (from their perspective) because node-gyp is being run as jesse (by npm), while $HOME is set to /root (by sudo).

The bug is that npm is invoking node-gyp as $SUDO_USER, not as $USER.

@darcyclarke darcyclarke added the Bug thing that needs fixing label Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is reproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants