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] npx not working on docker using root #3773

Closed
1 task done
gengjiawen opened this issue Sep 18, 2021 · 5 comments
Closed
1 task done

[BUG] npx not working on docker using root #3773

gengjiawen opened this issue Sep 18, 2021 · 5 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@gengjiawen
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

/bin/sh: 1: cargo: Permission denied
Error: Command failed: cargo install cargo-workspaces
/bin/sh: 1: cargo: Permission denied

    at checkExecSyncError (node:child_process:826:11)
    at execSync (node:child_process:900:15)
    at Object.<anonymous> (/pwd/scripts/bump_cargo_packages.ts:6:9)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module.m._compile (/pwd/node_modules/ts-node/src/index.ts:1310:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/pwd/node_modules/ts-node/src/index.ts:1313:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  status: 127,
  signal: null,
}

Expected Behavior

script run successfully.

Steps To Reproduce

git clone https://github.com/gengjiawen/monkey-rust
cd monkey-rust
docker run -v $PWD:/pwd -w /pwd gengjiawen/node-build bash -c "yarn && npx ts-node scripts/bump_cargo_packages.ts"

I have fallback to

docker run -v $PWD:/pwd -w /pwd gengjiawen/node-build bash -c "yarn && node node_modules/.bin/ts-node scripts/bump_cargo_packages.ts"

Environment

OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
Node: 16.9.1 - /usr/local/bin/node
npm: 7.24.0 - /usr/local/bin/npm

@gengjiawen gengjiawen added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Sep 18, 2021
@rashkov
Copy link

rashkov commented Jan 31, 2022

Have you seen #3110

As of npm CLI v7, "When npm is run as root, scripts are always run with the effective uid and gid of the working directory owner." https://docs.npmjs.com/cli/v7/using-npm/scripts#user

@wraithgar
Copy link
Member

This is the intended behavior in v7 and v8, as per the docs link above.

@gengjiawen
Copy link
Author

I have switch to pnpm to fix this. Have fun. pnpx is the equalient.

@papb
Copy link

papb commented Jul 27, 2022

@wraithgar Would you consider a feature request of a flag that allows overriding this behavior so that root is used? Or even a flag that allows us to specify which user we want?

@wraithgar
Copy link
Member

There is an ongoing discussion about this already in the rfc repo npm/rfcs#546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

4 participants