[BUG]bash_tool ignores $TMPDIR, fails on HPC systems on the newest claude code
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
- Connect to an HPC system where
/tmpis not user-writable (common on shared clusters) - Set
$TMPDIRto a user-writable location:
``bash``
export TMPDIR="$HOME/.tmp"
mkdir -p "$TMPDIR"
- Start Claude Code:
``bash``
claude
- Run any bash command, even simple ones like:
````
> pwd
Expected Behavior
Claude Code should:
- Respect the
$TMPDIRenvironment variable (POSIX standard) - Fall back to
$HOME/.claude/tmpif$TMPDIRis not set - Only use
/tmpas 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
$TMPDIRdoes 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:
- Shared filesystems: HPC clusters often have
/tmpas a system-managed tmpfs that users cannot write to - Node-local storage: Some clusters provide node-local
/tmpbut it's cleared between jobs - Quota systems: User home directories have quotas;
/tmpusage may be restricted - Security policies: Many institutions restrict
/tmpaccess for security reasons
Standard practice:
Most Unix tools respect the following hierarchy:
$TMPDIR(if set)$TEMP(if set)$TMP(if set)/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
noexecmounted/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_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗