[BUG] Bash tool execution consistently fails with temporary script file error on macOS
Status Closed — not planned
Maintainer reply ✓ Yes — dicksontsai
Workaround ✓ Mentioned in thread ↓
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
- Open Claude Code in any project directory
- Attempt to execute any Bash command using the Bash tool (e.g.,
rm file.txt,npm run test,ls -la, etc.) - 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
rmvs complexnpmcommands) - 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.
8 Comments
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.
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.
Additional Data Point: macOS 15.7.1 - Commands Work But Show Permission Errors
Environment
/Users/anon/.local/share/claude/versions/2.0.47Observed Behavior
Every bash command execution shows permission denied error for temp files, but commands execute successfully:
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:
claude doctorshows no issuesShell Configuration
Minimal
.zshrcand.bashrc(only PATH exports for pipx/local bin), so not related to complex shell configs.Attempted Fixes
sudo find /var/folders/.../T/ -name "claude-*-cwd" -deleteImpact
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.
Update: Upgrading to macOS 15.7.2 fixed this issue
I was experiencing the permission denied error on macOS 15.7.1 (BuildVersion: 24G231):
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.-Every Bash command shows:
The
xxxxportion changes with each command (appears to be a unique identifier per command execution).Example Output
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
Workaround
None available from within the session. The error cannot be suppressed by the user.
Additional Context
The error occurs consistently across:
ls,pwd)curl,python3)This suggests the issue is in the shell wrapper/executor, not in specific command types.
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.
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.
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.