[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:

  1. /tmp/claude directory does not exist on disk
  2. /tmp is mounted read-only inside the sandbox, so the directory **cannot be

created**

  1. The actual writable path is /tmp/claude-<UID>/ (e.g., /tmp/claude-1001/)
  2. settings.json env.TMPDIR is 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 TMPDIR to the actually existing and writable path

(/tmp/claude-<UID>/)

  • Sandbox should create /tmp/claude before mounting /tmp as read-only
  • settings.json env.TMPDIR should not be overridden by the sandbox

Error Messages/Logs

ENOENT: no such file or directory, mkdir '/tmp/claude'

Steps to Reproduce

  1. Enable sandbox in settings.json: "sandbox": { "enabled": true }
  2. Run any npm dev server that uses TMPDIR (e.g., Vite or Wrangler project): npm run dev
  3. Observe: ENOENT: no such file or directory, mkdir '/tmp/claude'
  4. Verify mismatch inside sandbox:
  • echo $TMPDIR/tmp/claude (forced by sandbox)
  • mkdir -p /tmp/claudeRead-only file system
  • ls /tmp/claude-1001/ → exists and writable
  1. 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.allowOnly list includes both /tmp/claude and /tmp/claude-1001/, but only

/tmp/claude-1001/ actually exists on disk

  • settings.json env.TMPDIR=/tmp/claude-1001 is set but overridden by the sandbox
  • This affects any tool spawned inside the sandbox that respects TMPDIR (Node.js, Python, Wrangler, Vite, etc.)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗