From 32df109a01f8b5c297ead194700f2612baa7ade2 Mon Sep 17 00:00:00 2001 From: frami Date: Mon, 25 May 2026 22:54:32 -0300 Subject: [PATCH] fix: prevent pnpm --- src/node/devcontainer-feature.json | 2 +- src/node/install.sh | 5 +++++ test/node/non_root_user.sh | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/node/devcontainer-feature.json b/src/node/devcontainer-feature.json index f9cdaa7..663b6f5 100644 --- a/src/node/devcontainer-feature.json +++ b/src/node/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "node", - "version": "1.0.0", + "version": "1.0.1", "name": "Node.js", "description": "Installs Node.js from the official nodejs.org prebuilt binaries, with optional npm and pnpm pinning. Assumes 'ghcr.io/devcontainers/features/common-utils:2' has run.", "documentationURL": "https://github.com/Synergy-Shock/devcontainer-features/tree/main/src/node", diff --git a/src/node/install.sh b/src/node/install.sh index 50c820d..893e84e 100755 --- a/src/node/install.sh +++ b/src/node/install.sh @@ -156,6 +156,11 @@ mkdir -p "${PNPM_HOME}" export PATH="${NPM_CONFIG_PREFIX}/bin:${PNPM_HOME}:${PATH}" pnpm --version +# Hand the global npm/pnpm trees to the remote user so non-root pnpm operations +# can write SQLite state (store index, WAL files) without "readonly database". +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${NPM_CONFIG_PREFIX}" +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${PNPM_HOME}" + # ------------------------------------------------------------------ # Persist env vars and PATH additions for future shells. # /etc/profile is sourced by login shells; common-utils:2 (a prerequisite) diff --git a/test/node/non_root_user.sh b/test/node/non_root_user.sh index a65ef59..247be80 100755 --- a/test/node/non_root_user.sh +++ b/test/node/non_root_user.sh @@ -4,4 +4,21 @@ source dev-container-features-test-lib check "node --version as non-root" bash -c "node --version | grep -E '^v[0-9]+\\.[0-9]+\\.[0-9]+'" check "pnpm --version as non-root" bash -c "pnpm --version | grep -E '^[0-9]+\\.[0-9]+\\.[0-9]+'" check "running as non-root" bash -c "test \"$(id -un)\" = 'vscode'" + +# Regression: pnpm v10.18+ opens a SQLite store index (WAL mode). A previous +# version of this feature left /usr/local/share/{npm-global,pnpm} root-owned, +# causing "ERR_SQLITE_ERROR: attempt to write a readonly database" on the +# first non-root `pnpm install`. `pnpm --version` does not exercise the store. +check "pnpm install as non-root" bash -c ' + set -e + d=$(mktemp -d) + cd "$d" + cat > package.json <