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

Task agent fails on Termux: EACCES permission denied for /tmp/claude

Open bitwizlabs opened this issue 10 months ago • 2 comments

Description

Task agents fail on Termux (Android) because Claude Code tries to create directories under /tmp/claude/, which doesn't exist on Termux and cannot be created without root.

Error

EACCES: permission denied, mkdir '/tmp/claude/-data-data-com-termux-files-home-donna/tasks'

Environment

  • Platform: Android (Termux)
  • Claude Code version: Latest from npm

Expected Behavior

Claude Code should respect $TMPDIR environment variable or use a fallback temp directory that works on Termux.

Termux Context

Termux uses /data/data/com.termux/files/usr/tmp as its temp directory. The standard /tmp doesn't exist and requires root to create.

Suggested Fix

Use $TMPDIR if set, falling back to /tmp only if $TMPDIR is not defined.

const tmpBase = process.env.TMPDIR || '/tmp';

Workaround Attempted

Setting TMPDIR in .bashrc does not resolve the issue, suggesting the path is hardcoded.

bitwizlabs avatar Jan 08 '26 22:01 bitwizlabs

Having same issue as well on v2.1.1

opariffazman avatar Jan 08 '26 23:01 opariffazman

Workaround Found

Until this is fixed upstream, you can use proot to bind Termux's temp directory to /tmp:

proot -b "$TMPDIR:/tmp" claude

Setup

  1. Install proot (if not already):

    pkg install proot
    
  2. Create a wrapper script or alias:

    alias claude='proot -b "$TMPDIR:/tmp" claude'
    

    Or for project-specific aliases:

    alias myproject='cd ~/myproject && proot -b $TMPDIR:/tmp claude --dangerously-skip-permissions'
    

How it works

proot intercepts filesystem calls and redirects /tmp to Termux's actual temp directory ($TMPDIR, typically /data/data/com.termux/files/usr/tmp). Claude Code sees /tmp as expected, but writes actually go to the Termux-accessible location.

Verified working

  • Task agents now spawn correctly
  • No noticeable performance impact
  • Full file access preserved (proot only binds the one path)

Hope this helps other Termux users while waiting for a proper fix.

bitwizlabs avatar Jan 14 '26 10:01 bitwizlabs

### This works, thank you!

Predragon avatar Jan 15 '26 18:01 Predragon

export CLAUDE_CODE_TMPDIR=$HOME/tmp/claude

source ~/.bashrc

HEYANGLI23 avatar Jan 19 '26 10:01 HEYANGLI23

Just tested this on Termux, works perfectly.

Agents spawn fine now. Much cleaner than the proot wrapper I was using before.

Thanks @HEYANGLI23

bitwizlabs avatar Jan 19 '26 19:01 bitwizlabs

Confirming: TMPDIR workaround does NOT work

Your observation is correct - setting TMPDIR in .bashrc or .profile does not resolve the issue.

My Configuration

# ~/.profile
export TMPDIR="$HOME/.cache/tmp"
export CLAUDE_CODE_TMPDIR="$HOME/.claude-tmp"

Both directories exist and are writable. Claude Code ignores both.

Evidence

Error still shows hardcoded path:

EACCES: permission denied, mkdir '/tmp/claude/-data-data-com-termux-files-home/tasks'

Environment

  • Node.js v24.13.0, npm 11.8.0
  • Termux on Android 13

Only Working Workaround

From issue #15628 - proot bind mount:

proot -b /data/data/com.termux/files/usr/tmp:/tmp claude

The suggested fix in your issue is correct:

const tmpBase = process.env.TMPDIR || '/tmp';

This is a simple one-line fix. 8+ duplicate issues remain open since December 2025.


Tested on Termux (TalkBack 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]