Sandbox sets TMPDIR to non-existent directory, causing child processes to hang
Status Fixed / completed
Maintainer reply ✓ Yes — ashwin-ant
Workaround ✓ Mentioned in description ↑
Activity 4 comments · opened Mar 20, 2026 · closed Apr 18, 2026
💡 Likely answer: A maintainer (ashwin-ant, collaborator)
responded on this thread — see the highlighted reply below.
Description
When running in sandbox mode, Claude Code sets TMPDIR=/tmp/claude and adds /tmp/claude to the filesystem write allowlist — but never actually creates the directory. Since /tmp itself is read-only within the sandbox, the directory cannot be created from inside the sandbox either.
This causes any tool that spawns child processes relying on os.tmpdir() (Node.js) or $TMPDIR for temp files, IPC, or worker communication to silently hang.
Steps to reproduce
- Start Claude Code in sandbox mode (fresh session or after reboot, so
/tmp/claudedoesn't exist) - Run any command that uses worker threads/child processes needing temp files — e.g.,
npm run testin a project using vitest
Observed behavior
TMPDIRis set to/tmp/claudeand inherited by child processes/tmp/claudedoes not exist as a directorymkdir -p /tmp/claudefails from within the sandbox withRead-only file system(because/tmpis not writable, only/tmp/claudeis in the allowlist)- Child processes (e.g., vitest worker threads) attempt to write IPC/temp files to the non-existent directory and block indefinitely
- Commands hang with no error message
Expected behavior
The sandbox should create the TMPDIR directory on startup before any commands are executed, since it cannot be created from within the sandbox.
Workaround
Manually create the directory with sandbox disabled:
mkdir -p /tmp/claude
This persists until reboot (since /tmp is typically tmpfs).
Environment
- Platform: Linux (Ubuntu, kernel 6.8.0-106-generic)
- Note: The sandbox also creates and uses
/tmp/claude-1000/which does exist — the inconsistency suggests/tmp/claudecreation was simply missed
4 Comments
This is a chicken-and-egg problem — the sandbox allows writes to
/tmp/claudebut/tmpitself is read-only, somkdir /tmp/claudefails.This points TMPDIR back to the writable
/tmpdirectory. Note: this may interact with sandbox restrictions depending on your configuration.Thanks @yurukusa, but what i really wanted here is the Claude Team to take note and implement a permanent fix
This was fixed in v2.1.101 — The sandbox now creates its TMPDIR before launching commands, so child processes that write to $TMPDIR no longer hang or fail. If you're still seeing this in the latest version, please comment with your version and repro and we'll reopen.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.