EACCES permission denied on /tmp/claude/* on Android/Termux
Description
Claude Code fails with EACCES: permission denied, mkdir '/tmp/claude/...' errors on Android/Termux when running commands that take more than a few seconds. The commands execute successfully, but Claude Code's internal task tracking fails because it tries to create directories in /tmp/claude/ which is inaccessible on Android.
Environment
- Claude Code version: 2.1.3
- Node version: v25.2.1
- Platform: Android 14 (Termux)
- Shell: bash
Error Message
EACCES: permission denied, mkdir '/tmp/claude/-storage-emulated-0-ai-projects-nas-admin/tasks'
Root Cause
- Claude Code hardcodes
/tmp/claude/...for internal task tracking - On Android,
/tmpis a system directory that apps cannot access - Termux uses
$TMPDIR(typically/data/data/com.termux/files/usr/tmp) instead of/tmp - Claude Code does not respect
$TMPDIRor$PREFIX/tmp
Reproduction Steps
- Install Claude Code on Termux (Android)
- Run any command that takes more than 2-3 seconds (e.g., SSH commands, API calls)
- Observe the EACCES error
Expected Behavior
Claude Code should use the platform-appropriate temp directory:
- Check
$TMPDIRfirst (set by Termux) - Fall back to
$PREFIX/tmpon Termux - Only use
/tmpas last resort on systems where it's accessible
Current Workaround
Run commands in the background and check results separately:
long_command > output.txt &
sleep 2
cat output.txt
Notes
- The actual commands execute successfully - only the task tracking fails
- This issue has been occurring since at least December 2025
- Affects all Claude Code sessions on Termux
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/16955
- https://github.com/anthropics/claude-code/issues/15637
- https://github.com/anthropics/claude-code/issues/15628
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
Partial Workaround Found
Setting TMPDIR in .bashrc helps for simple commands:
export TMPDIR="$HOME/.cache/tmp"
What Works ✅
- Simple single commands (apt, gcloud config)
- Commands with short execution time
What Still Fails ❌
- Background agents with
run_in_background: true - Long-running commands (apt upgrade, npm updates >10s)
- Tool chains with multiple sequential operations
Root Cause
Claude Code appears to hardcode /tmp/claude/ within the Node.js process, ignoring the TMPDIR environment variable set in shell rc files. Setting TMPDIR only affects child processes, not Claude Code's internal task tracking.
Evidence
- Direct command execution: ✅ Works
- Background task execution: ❌ Still fails with same EACCES error
- npm/gcloud component updates: ❌ Still blocked despite TMPDIR set
The environment variable workaround is incomplete. Requires fix in Claude Code source to use process.env.TMPDIR or os.tmpdir() instead of hardcoded paths.
Update: Partial Fix on v2.1.11, But Agents Still Broken
Environment Verified
- Claude Code Version: 2.1.11
- Android Version: 13
- Device: Samsung Galaxy (aarch64)
- Kernel: Linux 5.15.178-android13-8
- Termux: Latest
- Node.js: v25.2.1
Status: MIXED RESULTS
✅ FIXED (Partially):
- Direct Bash commands now work without
/tmp/claudeerrors - Long-running commands like
ffmpegexecute successfully
❌ STILL BROKEN (Critical):
- Agent spawning:
EACCES: permission denied - Background task creation:
EACCES: permission denied - Task tool with
run_in_background: true: Fails
Example Failure
Task tool error:
EACCES: permission denied, mkdir '/tmp/claude/-data-data-com-termux-files-home/tasks'
What the Update Fixed
Appears to have optimized direct command execution path, but did NOT address the task infrastructure that agents depend on.
What Still Needs Fixing
The internal task spawning system still hardcodes /tmp/claude/ and doesn't respect $TMPDIR.
Accessibility Impact
- Users can work around by using Bash tool directly
- But cannot use agent-based workflows
- Blocks multi-step automation and parallel task execution
export CLAUDE_CODE_TMPDIR=$HOME/tmp/claude
source ~/.bashrc
I ran into the same issue with Claude Code v2.1.19 on Linux based remote server. I used the suggestion to set local tmp dir and running ls -l via Bash with run_in_background completed instantly (output file exists with correct content), but TaskOutput with 30-second timeout still timed out. Took ~3 minutes to retrieve results. The command executed quickly but there's a delay in the TaskOutput retrieval mechanism.
Another confirmation: Environment variables ignored
Same issue on my Termux setup. Configuration in ~/.profile:
export TMPDIR="$HOME/.cache/tmp"
export CLAUDE_CODE_TMPDIR="$HOME/.claude-tmp"
Both directories exist. Claude Code still fails with:
EACCES: permission denied, mkdir '/tmp/claude/-data-data-com-termux-files-home/tasks'
Environment
- Android 13 / Termux
- Node.js v24.13.0
- npm 11.8.0
Confirmed
Your root cause analysis is correct:
- Claude Code hardcodes
/tmp/claude/... - Does NOT respect
$TMPDIR - Does NOT use
os.tmpdir()
Working Workaround
Only proot bind mount works (from #15628):
proot -b /data/data/com.termux/files/usr/tmp:/tmp claude
This issue has 8+ duplicates open since December 2025. Requesting prioritization of this fix.
Reported from Termux (accessibility user)
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
Workaround: https://github.com/anthropics/claude-code/pull/31701#issuecomment-4017294725
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.