Sandbox sets TMPDIR=/tmp/claude but writable dir is /tmp/claude-$UID

Resolved 💬 7 comments Opened Feb 27, 2026 by widefox Closed Apr 18, 2026

Summary

The sandbox injects TMPDIR=/tmp/claude into the environment, but the actual writable temporary directory is /tmp/claude-$UID (e.g., /tmp/claude-1000). The path in TMPDIR does not exist, causing tools that rely on TMPDIR (e.g., make) to emit warnings.

Reproduction

  1. Enable sandbox in settings: "sandbox": {"enabled": true}
  2. Run any session and check:
echo "TMPDIR=$TMPDIR"                  # /tmp/claude
echo "CLAUDE_CODE_TMPDIR=$CLAUDE_CODE_TMPDIR"  # /tmp/claude-1000
ls -d /tmp/claude                      # No such file or directory
ls -d /tmp/claude-1000                 # exists

Observed behavior

\\\
$ make status
make: TMPDIR value /tmp/claude: No such file or directory
make: using default temporary directory '/tmp'
\
\\

  • \TMPDIR=/tmp/claude\ — set by sandbox, directory does not exist
  • \CLAUDE_CODE_TMPDIR=/tmp/claude-1000\ — actual writable temp dir, does exist
  • User UID is 1000, so the suffix is \-1000\

Expected behavior

\TMPDIR\ should point to the same writable directory as \CLAUDE_CODE_TMPDIR\, i.e., \/tmp/claude-$UID\.

Environment

  • Claude Code v2.1.27+
  • Linux (Fedora, uid 1000)
  • \"sandbox": {"enabled": true, "autoAllowBashIfSandboxed": true}\

View original on GitHub ↗

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