claude-code
claude-code copied to clipboard
[BUG] Background tasks ignore $TMPDIR and hardcode /tmp/claude/
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
$TMPDIRset to a valid, writable directory (e.g.,/run/user/$(id -u)) - Ensure
/tmpis not writable by the current user - Run a background task in Claude Code (e.g.,
run_in_background: trueon 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.