Skip to content

Commit a8f0b45

Browse files
brianhelbaabdurriq
andauthored
[node] - Install pnpm as non-root user to prevent root-owned npm cache (#1625)
* [node] - Install pnpm as non-root user to prevent root-owned npm cache 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. * Bump Node.js version to 2.1.0 --------- Co-authored-by: Abdurrahmaan Iqbal <abdurriq@github.com>
1 parent 7ae907d commit a8f0b45

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

src/node/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "node",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"name": "Node.js (via nvm), yarn and pnpm.",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/node",
66
"description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.",

src/node/install.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,7 @@ if [ ! -z "${PNPM_VERSION}" ] && [ "${PNPM_VERSION}" = "none" ]; then
482482
echo "Ignoring installation of PNPM"
483483
else
484484
if bash -c ". '${NVM_DIR}/nvm.sh' && type npm >/dev/null 2>&1"; then
485-
(
486-
. "${NVM_DIR}/nvm.sh"
487-
[ ! -z "$http_proxy" ] && npm set proxy="$http_proxy"
488-
[ ! -z "$https_proxy" ] && npm set https-proxy="$https_proxy"
489-
[ ! -z "$no_proxy" ] && npm set noproxy="$no_proxy"
490-
npm install -g pnpm@$PNPM_VERSION --force
491-
)
485+
su ${USERNAME} -c "umask 0002 && . '${NVM_DIR}/nvm.sh' && npm install -g pnpm@${PNPM_VERSION} --force"
492486
else
493487
echo "Skip installing pnpm because npm is missing"
494488
fi

0 commit comments

Comments
 (0)