Description
Claude Code's background task system ignores the $TMPDIR environment variable and hardcodes /tmp/claude/ for task management, causing permission denied errors when /tmp is not writable by the user.
Steps to Reproduce
- Have
$TMPDIR set to a valid, writable directory (e.g., /run/user/$(id -u))
- Ensure
/tmp is not writable by the current user
- Run a background task in Claude Code (e.g.,
run_in_background: true on a Bash command)
Expected Behavior
Claude Code should respect $TMPDIR and create its task directory there.
Actual Behavior
Claude Code ignores $TMPDIR and attempts to create /tmp/claude/<workspace-path>/tasks, resulting in:
EACCES: permission denied, mkdir '/tmp/claude/-mnt-nw-home-c-dumas-research-libs-nnsight/tasks'
Environment
- OS: Linux 6.8.0-60-generic (Ubuntu)
- TMPDIR:
/run/user/2011 (set and valid)
- Claude Code version: Latest
Notes
This is distinct from existing issues like #10194 (TMPDIR pointing to non-existent directory) and #14799 (EXDEV with tmpfs). In this case, $TMPDIR is correctly set to a valid, writable directory, but Claude Code completely ignores it for the background task system.
Description
Claude Code's background task system ignores the
$TMPDIRenvironment variable and hardcodes/tmp/claude/for task management, causing permission denied errors when/tmpis not writable by the user.Steps to Reproduce
$TMPDIRset to a valid, writable directory (e.g.,/run/user/$(id -u))/tmpis not writable by the current userrun_in_background: trueon a Bash command)Expected Behavior
Claude Code should respect
$TMPDIRand create its task directory there.Actual Behavior
Claude Code ignores
$TMPDIRand attempts to create/tmp/claude/<workspace-path>/tasks, resulting in:Environment
/run/user/2011(set and valid)Notes
This is distinct from existing issues like #10194 (TMPDIR pointing to non-existent directory) and #14799 (EXDEV with tmpfs). In this case,
$TMPDIRis correctly set to a valid, writable directory, but Claude Code completely ignores it for the background task system.