[BUG]bash_tool ignores $TMPDIR, fails on HPC systems on the newest claude code

Resolved 💬 4 comments Opened Jan 24, 2026 by lehrach Closed Mar 1, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Description

Claude Code's bash_tool fails with permission denied errors on HPC (High Performance Computing) systems where /tmp is not writable by users. The tool appears to hardcode /tmp/claude/... for task tracking, ignoring the standard $TMPDIR environment variable.

Steps to Reproduce

  1. Connect to an HPC system where /tmp is not user-writable (common on shared clusters)
  2. Set $TMPDIR to a user-writable location:

``bash
export TMPDIR="$HOME/.tmp"
mkdir -p "$TMPDIR"
``

  1. Start Claude Code:

``bash
claude
``

  1. Run any bash command, even simple ones like:

``
> pwd
``

Expected Behavior

Claude Code should:

  1. Respect the $TMPDIR environment variable (POSIX standard)
  2. Fall back to $HOME/.claude/tmp if $TMPDIR is not set
  3. Only use /tmp as a last resort, and fail gracefully with a helpful error message if not writable

Actual Behavior

Error: EACCES: permission denied, mkdir '/tmp/claude/tasks/...'

The command fails completely. Even trivial commands like pwd, ls, or echo do not work.

Impact

  • Severity: Critical - Claude Code is completely unusable on affected systems
  • Affected users: Anyone on HPC clusters, shared servers, or systems with restricted /tmp
  • Workaround: None available - setting $TMPDIR does not help

Proposed Solution

// Current (broken):
const TASK_DIR = '/tmp/claude/tasks';

// Proposed fix:
const TASK_DIR = process.env.TMPDIR 
  ? path.join(process.env.TMPDIR, 'claude', 'tasks')
  : process.env.HOME
    ? path.join(process.env.HOME, '.claude', 'tmp', 'tasks')
    : '/tmp/claude/tasks';

Or use Node.js os.tmpdir() which already respects $TMPDIR:

const os = require('os');
const TASK_DIR = path.join(os.tmpdir(), 'claude', 'tasks');

Additional Context

Why this matters for HPC users:

  1. Shared filesystems: HPC clusters often have /tmp as a system-managed tmpfs that users cannot write to
  2. Node-local storage: Some clusters provide node-local /tmp but it's cleared between jobs
  3. Quota systems: User home directories have quotas; /tmp usage may be restricted
  4. Security policies: Many institutions restrict /tmp access for security reasons

Standard practice:

Most Unix tools respect the following hierarchy:

  1. $TMPDIR (if set)
  2. $TEMP (if set)
  3. $TMP (if set)
  4. /tmp (fallback)

Node.js's os.tmpdir() already implements this correctly.

System Information

$ echo $TMPDIR
/home/user/.tmp

$ ls -la /tmp
ls: cannot access '/tmp': Permission denied
# OR
drwxr-xr-x 2 root root 4096 Jan 1 00:00 /tmp  # exists but not writable

$ claude --version
Claude Code vX.X.X

Related Issues

  • This may affect Docker containers with read-only /tmp
  • This may affect systems with noexec mounted /tmp
  • This may affect any system with non-standard temp directory configuration

---

Submitted by: [Hans Lehrach]
Date: January 24, 2025
GitHub: https://github.com/anthropics/claude-code/issues

What Should Happen?

claude should be able to carry out bash commands without the need for a /tmp directory, which does not exist in our installation (and can not be user installed)

Error Messages/Logs

Steps to Reproduce

pwd

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.19 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗