[BUG] Bash tool execution consistently fails with temporary script file error on macOS

Status Closed — not planned
Maintainer reply ✓ Yes — dicksontsai
Activity 8 comments · opened Jul 3, 2025 · closed Jan 30, 2026
💡 Likely answer: A maintainer (dicksontsai, collaborator) responded on this thread — see the highlighted reply below.

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.41 (Claude Code)
  • Operating System: macOS (Darwin 24.3.0)
  • Terminal: WebStorm

Bug Description

All Bash tool executions in Claude Code consistently fail with a "no such file or directory" error related to temporary script files. The error appears to be
related to Claude Code's internal mechanism for creating temporary script files when executing Bash commands.

Steps to Reproduce

  1. Open Claude Code in any project directory
  2. Attempt to execute any Bash command using the Bash tool (e.g., rm file.txt, npm run test, ls -la, etc.)
  3. Observe the consistent error message

Expected Behavior

Bash commands should execute normally and return their output or complete their operations successfully.

Actual Behavior

Every Bash command execution fails with the same error:
zsh:source:1: no such file or directory: /var/folders/7h/3tkbrsgj4w5801549byjrplw0000gn/T/claude-shell-snapshot-f7f2

The error occurs regardless of:

  • The specific command being executed
  • The command complexity (simple rm vs complex npm commands)
  • The target files or directories

Additional Context

  • Affected Tools: Only the Bash tool is affected
  • Working Tools: Read, Write, Edit, LS, Glob, Grep tools work normally
  • Workarounds: Using Task tool or alternative methods (Write tool for file deletion)
  • Error Pattern: The temporary file path remains consistent across different command attempts
  • Session Persistence: The issue persists throughout the entire Claude Code session

This appears to be a bug in Claude Code's internal temporary script file generation mechanism for Bash command execution.

View original on GitHub ↗

8 Comments

dicksontsai collaborator · 1 year ago

Unfortunately, Claude Code doesn't work will with certain zshrc/bashrc. (I encountered this same issue when I onboarded.) Handling all possible failure modes of zshrc processing is difficult, so I would recommend seeing what you can take out of zshrc to avoid the snapshot errors.

almirsarajcic · 1 year ago

I've switched completely to bash, set up .bash_profile just for Claude Code to include just a few tools I need, and still, it didn't work.

Related to https://github.com/anthropics/claude-code/issues/2139.

lukedyer-uipath · 10 months ago

Additional Data Point: macOS 15.7.1 - Commands Work But Show Permission Errors

Environment

  • Claude Code Version: 2.0.47 (native installation)
  • macOS Version: 15.7.1 (24G231)
  • Darwin Version: 24.6.0
  • Shell: zsh (with fish as default terminal)
  • Installation Method: native
  • Installation Path: /Users/anon/.local/share/claude/versions/2.0.47
  • Auto-updates: enabled (default)

Observed Behavior

Every bash command execution shows permission denied error for temp files, but commands execute successfully:

zsh:1: permission denied: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/claude-XXXX-cwd
[actual command output appears correctly]

The temp file ID changes on each command (e.g., claude-f5b1-cwd, claude-1ab8-cwd, claude-ad78-cwd, claude-b756-cwd).

Key Difference from Other Reports

Unlike some reports where bash commands fail completely, in this case:

  • ✅ Commands execute and return correct results
  • ❌ Permission error appears in stderr before output
  • ❌ New temp file created each time with same permission issue
  • ✅ All other Claude Code tools work normally
  • ✅ claude doctor shows no issues

Shell Configuration

Minimal .zshrc and .bashrc (only PATH exports for pipx/local bin), so not related to complex shell configs.

Attempted Fixes

  • Deleted temp files with sudo find /var/folders/.../T/ -name "claude-*-cwd" -delete
  • Files are recreated immediately with same permissions issue
  • Error persists across new temp file IDs
  • Restarting Claude Code doesn't help

Impact

Cosmetic but annoying - creates visual clutter in all bash command outputs making it harder to read actual results. Additionally, the repeated "permission denied" errors give the impression that Claude Code is broken or malfunctioning, which is confusing for users when the commands are actually executing successfully.

lukedyer-uipath · 10 months ago

Update: Upgrading to macOS 15.7.2 fixed this issue

I was experiencing the permission denied error on macOS 15.7.1 (BuildVersion: 24G231):

zsh:1: permission denied: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/claude-XXXX-cwd

After upgrading to macOS 15.7.2 (BuildVersion: 24G325), the permission errors are gone and bash commands work without issues.

Important note: Just restarting on 15.7.1 did NOT fix it - the actual OS update to 15.7.2 was required.

The underlying /var/folders/zz/ directory still has incorrect permissions (owned by root:wheel), but applications are no longer trying to use it, so the practical issue is resolved.

sysingleton · 10 months ago
  • OS: macOS Darwin 24.6.0
  • Claude Code version: 2.0.55
  • Shell: zsh

-Every Bash command shows:

zsh:1: permission denied: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/claude-xxxx-cwd

[actual command output here]

The xxxx portion changes with each command (appears to be a unique identifier per command execution).

Example Output

$ curl -s http://localhost:5001/api/health

# Actual output received:
zsh:1: permission denied: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/claude-f7aa-cwd

{
  "message": "RhythmRally Engine Online",
  "status": "ok"
}

Hypothesis

Claude Code appears to use temp files (claude-xxxx-cwd) to track shell working directory state. The macOS sandbox may be restricting write access to /var/folders/zz/ (the system temp folder for sandboxed/restricted apps).

The path /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/ suggests this is hitting the "nobody" user's temp folder, which has restricted permissions.

Impact

  • Severity: Low (cosmetic)
  • Functional impact: None - commands execute successfully
  • User experience impact: High - error messages are confusing and appear on every single command

Workaround

None available from within the session. The error cannot be suppressed by the user.

Additional Context

The error occurs consistently across:

  • Simple commands (ls, pwd)
  • Complex commands (curl, python3)
  • Piped commands
  • Background commands

This suggests the issue is in the shell wrapper/executor, not in specific command types.

github-actions[bot] · 9 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 8 months ago

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.