claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

EACCES permission denied on /tmp/claude/* on Android/Termux

Open Arielgb2 opened this issue 10 months ago • 1 comments

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

  1. Claude Code hardcodes /tmp/claude/... for internal task tracking
  2. On Android, /tmp is a system directory that apps cannot access
  3. Termux uses $TMPDIR (typically /data/data/com.termux/files/usr/tmp) instead of /tmp
  4. Claude Code does not respect $TMPDIR or $PREFIX/tmp

Reproduction Steps

  1. Install Claude Code on Termux (Android)
  2. Run any command that takes more than 2-3 seconds (e.g., SSH commands, API calls)
  3. Observe the EACCES error

Expected Behavior

Claude Code should use the platform-appropriate temp directory:

  • Check $TMPDIR first (set by Termux)
  • Fall back to $PREFIX/tmp on Termux
  • Only use /tmp as 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

Arielgb2 avatar Jan 10 '26 19:01 Arielgb2

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/16955
  2. https://github.com/anthropics/claude-code/issues/15637
  3. 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

github-actions[bot] avatar Jan 10 '26 19:01 github-actions[bot]

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.

salviz avatar Jan 14 '26 05:01 salviz

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/claude errors
  • Long-running commands like ffmpeg execute 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

salviz avatar Jan 17 '26 07:01 salviz

export CLAUDE_CODE_TMPDIR=$HOME/tmp/claude

source ~/.bashrc

HEYANGLI23 avatar Jan 19 '26 10:01 HEYANGLI23

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.

s-canchi avatar Jan 26 '26 23:01 s-canchi

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:

  1. Claude Code hardcodes /tmp/claude/...
  2. Does NOT respect $TMPDIR
  3. 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)

salviz avatar Feb 01 '26 15:02 salviz

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] avatar Mar 02 '26 22:03 github-actions[bot]

Workaround: https://github.com/anthropics/claude-code/pull/31701#issuecomment-4017294725

rios0rios0 avatar Mar 07 '26 20:03 rios0rios0

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.

github-actions[bot] avatar Mar 15 '26 14:03 github-actions[bot]