Skip to content

Commit ce5445a

Browse files
committed
[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.
1 parent 87bc907 commit ce5445a

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

src/node/install.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,7 @@ if [ ! -z "${PNPM_VERSION}" ] && [ "${PNPM_VERSION}" = "none" ]; then
386386
echo "Ignoring installation of PNPM"
387387
else
388388
if bash -c ". '${NVM_DIR}/nvm.sh' && type npm >/dev/null 2>&1"; then
389-
(
390-
. "${NVM_DIR}/nvm.sh"
391-
[ ! -z "$http_proxy" ] && npm set proxy="$http_proxy"
392-
[ ! -z "$https_proxy" ] && npm set https-proxy="$https_proxy"
393-
[ ! -z "$no_proxy" ] && npm set noproxy="$no_proxy"
394-
npm install -g pnpm@$PNPM_VERSION --force
395-
)
389+
su ${USERNAME} -c "umask 0002 && . '${NVM_DIR}/nvm.sh' && npm install -g pnpm@${PNPM_VERSION} --force"
396390
else
397391
echo "Skip installing pnpm because npm is missing"
398392
fi

0 commit comments

Comments
 (0)