Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions test/node/non_root_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<JSON
{ "name": "t", "version": "0.0.0", "dependencies": { "is-odd": "3.0.1" } }
JSON
pnpm config set store-dir "$d/.pnpm-store"
pnpm install --no-frozen-lockfile --ignore-scripts
test -d "$d/node_modules/is-odd"
'

reportResults