EACCES: permission denied on Termux/Android - hardcoded /tmp path ignores $TMPDIR
Description
Claude Code fails to execute certain operations on Termux (Android) because it tries to create directories under /tmp/claude/ instead of respecting the $TMPDIR environment variable.
Environment
- Platform: Android (Termux)
- OS: Linux 6.6.77-android15
- Claude Code version: Latest
- $TMPDIR:
/data/data/com.termux/files/usr/tmp
Error
EACCES: permission denied, mkdir '/tmp/claude/-data-data-com-termux-files-home/tasks'
Root Cause
On Android/Termux, /tmp exists but is owned by shell:shell with 0771 permissions. Non-root users cannot create directories there. Termux correctly sets $TMPDIR to a writable location (/data/data/com.termux/files/usr/tmp), but Claude Code ignores this environment variable and hardcodes /tmp.
Expected Behavior
Claude Code should use $TMPDIR (or os.tmpdir() in Node.js which respects it) instead of hardcoding /tmp.
Affected Operations
curlandwgetdownloads- Background task execution
- Agent spawning and task delegation - Agents fail to launch because they cannot create task directories
- Any operation that spawns background processes
Impact
This effectively breaks agent-based workflows on Termux/Android, significantly limiting Claude Code's capabilities on mobile devices.
Workaround
Users must run downloads, background tasks, and agent-equivalent operations directly in terminal, bypassing Claude Code entirely.
Suggested Fix
Replace hardcoded /tmp references with:
const os = require('os');
const tmpDir = os.tmpdir(); // Respects $TMPDIR
Or explicitly check process.env.TMPDIR before falling back to /tmp.
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗