[BUG] Sandbox sets TMPDIR=/tmp/claude but directory doesn't exist and /tmp is read-only
Resolved 💬 2 comments Opened Mar 3, 2026 by nobuhiro-sasaki Closed Mar 3, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The sandbox (bubblewrap) sets TMPDIR=/tmp/claude as an environment variable, but:
/tmp/claudedirectory does not exist on disk/tmpis mounted read-only inside the sandbox, so the directory **cannot be
created**
- The actual writable path is
/tmp/claude-<UID>/(e.g.,/tmp/claude-1001/) settings.jsonenv.TMPDIRis overridden by the sandbox's forced TMPDIR
This causes any tool that writes to $TMPDIR (e.g., Vite/Wrangler via npm run) to fail with ENOENT.
What Should Happen?
One of:
- Sandbox should set
TMPDIRto the actually existing and writable path
(/tmp/claude-<UID>/)
- Sandbox should create
/tmp/claudebefore mounting/tmpas read-only settings.jsonenv.TMPDIRshould not be overridden by the sandbox
Error Messages/Logs
ENOENT: no such file or directory, mkdir '/tmp/claude'
Steps to Reproduce
- Enable sandbox in
settings.json:"sandbox": { "enabled": true } - Run any npm dev server that uses TMPDIR (e.g., Vite or Wrangler project):
npm run dev - Observe:
ENOENT: no such file or directory, mkdir '/tmp/claude' - Verify mismatch inside sandbox:
echo $TMPDIR→/tmp/claude(forced by sandbox)mkdir -p /tmp/claude→Read-only file systemls /tmp/claude-1001/→ exists and writable
- Workaround confirms the cause:
TMPDIR=/tmp/claude-1001 npm run dev→ works
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.63 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
- Environment: WSL2 (Ubuntu) on Windows, WezTerm terminal
- UID: 1001 (non-root user)
- The
write.allowOnlylist includes both/tmp/claudeand/tmp/claude-1001/, but only
/tmp/claude-1001/ actually exists on disk
settings.jsonenv.TMPDIR=/tmp/claude-1001is set but overridden by the sandbox- This affects any tool spawned inside the sandbox that respects
TMPDIR(Node.js, Python, Wrangler, Vite, etc.)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗