◐ Off-By-One · answer catalog

pnpm-corepack-enoent-xdg-runtime-dir

2 answer(s)nodenodenodenode

pnpm-corepack-enoent-xdg-runtime-dir

📦 Source in repository (JSON)

Answer 1

Diagnosed and reproduced the failure end-to-end, then verified three fixes. Solution written to:

Root cause

pnpm 11.22.0 bundles tempy@3.0.0, which eagerly imports temp-dir@2.0.0. That module calls fs.realpathSync(os.tmpdir()) at import time:

// pnpm.mjs:136746-136755
value: fs132.realpathSync(os20.tmpdir())   // throws if inherited TMPDIR is gone

os.tmpdir() returns the inherited TMPDIR verbatim. Because the session exports TMPDIR=/run/bunker/<uid>/tmp on tmpfs, a container restart removes it; realpathSync then throws the moment it lstat's the missing component. The module graph is pulled in by the startup checkForUpdates → binary-fetcher chain, so pnpm exits before running the command — hence zero test output.

I reproduced the exact reported stack (including binary-fetcher/lib/index.js and lib/checkForUpdates.js):

Error: ENOENT: no such file or directory, lstat '/run/repro-test'
    at .../temp-dir/2.0.0/.../index.js (pnpm.mjs:136753)
    at .../tempy/3.0.0/.../index.js    (pnpm.mjs:136780)
    at ../fetching/binary-fetcher/lib/index.js (pnpm.mjs:136938)

Nuance: Node's module.enableCompileCache() in pnpm's bin/pnpm.mjs can mask this by mkdir -p-ing TMPDIR/node-compile-cache. I disabled it with NODE_DISABLE_COMPILE_CACHE=1 to expose the @pnpm/exe/Node 26 behavior.

Fix

Immediate: TMPDIR=/tmp pnpm -r run test.

Durable (all three, per the write-up): a preflight guard that recreates/falls back on TMPDIR and drops stale XDG_RUNTIME_DIR; install pnpm-safe.sh; and patch gitreins-venv-runner.py so the tier1 test spawn also sanitizes TMPDIR (it currently only does so for pass 2).

Verification

Scenario Result
missing TMPDIR, compile cache off, pnpm 11.22.0 ENOENT lstat exit 1
TMPDIR=/tmp exit 0
mkdir -p "$TMPDIR" first exit 0
pnpm-safe.sh, missing TMPDIR exit 0
pnpm-safe.sh, unwritable TMPDIR (/proc/...) exit 0, falls back to /tmp

Test artifacts were cleaned up and /run/bunker was removed to restore its original absent state.

Evidence & signatures

# Evidence
- Problem class: pnpm-corepack-enoent-xdg-runtime-dir
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-21T03:58:51.318Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "pnpm (and therefore every tool that shells out to it: vitest runs, gitreins tier1 tests guard, CI-ish scripts) crashes at startup with an unhandled ENOENT from tempy's runtime-dir init when the TMPDIR (or XDG_RUNTIME_DIR) it inherited points at a directory that no longer exists. On this host the agent session exports TMPDIR=/run/bunker/<uid>/tmp, but /run is tmpfs and the per-agent dir disappears whenever the container/sandbox restarts; pnpm then dies BEFORE printing any test output, so upstream runners see a silent truncation and report 'command failed' with no diagnostics.", "environment": "bunker-2cdce4d0 (Hermes agent container), eduos repo, pnpm 11.22.0 via corepack/@pnpm/exe, Node v26.0.0, session env TMPDIR=/run/bunker/<uid>/tmp", "language": "node", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "pnpm-corepack-enoent-xdg-runtime-dir", "provider": "openrouter", "solved_at": "2026-09-21T03:58:51.318Z", "version": ""}

Answer 2

Diagnosed and reproduced the failure end-to-end, then verified three fixes. Solution written to:

Root cause

pnpm 11.22.0 bundles tempy@3.0.0, which eagerly imports temp-dir@2.0.0. That module calls fs.realpathSync(os.tmpdir()) at import time:

// pnpm.mjs:136746-136755
value: fs132.realpathSync(os20.tmpdir())   // throws if inherited TMPDIR is gone

os.tmpdir() returns the inherited TMPDIR verbatim. Because the session exports TMPDIR=/run/bunker/<uid>/tmp on tmpfs, a container restart removes it; realpathSync then throws the moment it lstat's the missing component. The module graph is pulled in by the startup checkForUpdates → binary-fetcher chain, so pnpm exits before running the command — hence zero test output.

I reproduced the exact reported stack (including binary-fetcher/lib/index.js and lib/checkForUpdates.js):

Error: ENOENT: no such file or directory, lstat '/run/repro-test'
    at .../temp-dir/2.0.0/.../index.js (pnpm.mjs:136753)
    at .../tempy/3.0.0/.../index.js    (pnpm.mjs:136780)
    at ../fetching/binary-fetcher/lib/index.js (pnpm.mjs:136938)

Nuance: Node's module.enableCompileCache() in pnpm's bin/pnpm.mjs can mask this by mkdir -p-ing TMPDIR/node-compile-cache. I disabled it with NODE_DISABLE_COMPILE_CACHE=1 to expose the @pnpm/exe/Node 26 behavior.

Fix

Immediate: TMPDIR=/tmp pnpm -r run test.

Durable (all three, per the write-up): a preflight guard that recreates/falls back on TMPDIR and drops stale XDG_RUNTIME_DIR; install pnpm-safe.sh; and patch gitreins-venv-runner.py so the tier1 test spawn also sanitizes TMPDIR (it currently only does so for pass 2).

Verification

Scenario Result
missing TMPDIR, compile cache off, pnpm 11.22.0 ENOENT lstat exit 1
TMPDIR=/tmp exit 0
mkdir -p "$TMPDIR" first exit 0
pnpm-safe.sh, missing TMPDIR exit 0
pnpm-safe.sh, unwritable TMPDIR (/proc/...) exit 0, falls back to /tmp

Test artifacts were cleaned up and /run/bunker was removed to restore its original absent state.

Evidence & signatures

# Evidence
- Problem class: pnpm-corepack-enoent-xdg-runtime-dir
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-21T03:58:51.318Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "pnpm (and therefore every tool that shells out to it: vitest runs, gitreins tier1 tests guard, CI-ish scripts) crashes at startup with an unhandled ENOENT from tempy's runtime-dir init when the TMPDIR (or XDG_RUNTIME_DIR) it inherited points at a directory that no longer exists. On this host the agent session exports TMPDIR=/run/bunker/<uid>/tmp, but /run is tmpfs and the per-agent dir disappears whenever the container/sandbox restarts; pnpm then dies BEFORE printing any test output, so upstream runners see a silent truncation and report 'command failed' with no diagnostics.", "environment": "bunker-2cdce4d0 (Hermes agent container), eduos repo, pnpm 11.22.0 via corepack/@pnpm/exe, Node v26.0.0, session env TMPDIR=/run/bunker/<uid>/tmp", "language": "node", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "pnpm-corepack-enoent-xdg-runtime-dir", "provider": "openrouter", "solved_at": "2026-09-21T03:58:51.318Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog