Skip to content

[node] - Install pnpm as non-root user to prevent root-owned npm cache#1625

Open
brianhelba wants to merge 1 commit intodevcontainers:mainfrom
brianhelba:node-root
Open

[node] - Install pnpm as non-root user to prevent root-owned npm cache#1625
brianhelba wants to merge 1 commit intodevcontainers:mainfrom
brianhelba:node-root

Conversation

@brianhelba
Copy link
Copy Markdown

Currently, the pnpm installation block runs npm install -g pnpm in a bare subshell as root, unlike every other npm/nvm operation in the script which uses su ${USERNAME}. This causes the npm cache directory to be created owned by root:root, leading to EACCES errors for the non-root user on subsequent npm operations.

This is particularly reproducible on macOS with Rosetta 2 emulation, where the cache directory may not already exist from prior steps.

Note, the explicit setting of proxy env vars (http_proxy, https_proxy, no_proxy) is likely a workaround for npm/cli#6835. No other commands in this script use that workaround anymore, so this change uses the same su syntax as all other commands.

Currently, the pnpm installation block runs `npm install -g pnpm` in
a bare subshell as root, unlike every other npm/nvm operation in the
script which uses `su ${USERNAME}`. This causes the npm cache directory
to be created owned by `root:root`, leading to `EACCES` errors for the
non-root user on subsequent npm operations.

This is particularly reproducible on macOS with Rosetta 2 emulation,
where the cache directory may not already exist from prior steps.

Note, the explicit setting of proxy env vars (`http_proxy`, `https_proxy`,
`no_proxy`) is likely a workaround for npm/cli#6835.
No other commands in this script use that workaround anymore, so this change
uses the same `su` syntax as all other commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant