[BUG] Bash tool fails with EEXIST on session-env directory mid-session (Windows)
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
After some Bash tool calls succeed early in a session, all subsequent Bash tool
calls fail with:
EEXIST: file already exists, mkdir 'C:\Users\<username>\.claude\session-env\<session-uuid>'
The session-env directory is created by Claude Code at session start. The Bash
tool then tries to recreate it on every call, which fails on Windows because the
directory already exists.
Steps to Reproduce
- Start a Claude Code session on Windows 11
- Run several Bash tool calls (they may succeed initially)
- At some point mid-session, all Bash calls start failing with EEXIST
Expected Behavior
The Bash tool should work throughout the entire session.
Actual Behavior
All Bash tool calls fail with EEXIST after a certain point in the session.
Workaround
Manually deleting the session-env directory doesn't help — it gets recreated
immediately and the next Bash call fails again.
The ! prefix (direct shell execution) works in bash shells but not PowerShell.
Environment
- OS: Windows 11 Pro 10.0.26200
- Shell: PowerShell (default)
- Claude Code: Desktop App
Related Issues
- #31460 — Write/Edit EEXIST
- #31030 — startup EEXIST
What Should Happen?
The Bash tool should work reliably throughout the entire session without any EEXIST
errors. The session-env directory creation should be idempotent — if the directory
already exists, it should succeed silently (equivalent to mkdir -p behavior).
Error Messages/Logs
EEXIST: file already exists, mkdir
'C:\Users\<username>\.claude\session-env\<session-uuid>''
Steps to Reproduce
- Start a Claude Code session on Windows 11
- Use the Bash tool a few times (may work initially)
- At some point mid-session, every Bash tool call starts failing with the EEXIST error
- Deleting the session-env directory manually does not help — the error persists
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.113 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
The bug occurs consistently mid-session. Early Bash tool calls in the same session may
succeed, but after a certain point all subsequent calls fail. Starting a new Claude Code
session creates a new session UUID and the issue disappears temporarily — until it occurs
again in that session.
Workaround: using the ! prefix to run commands directly in the shell (bash only, not
PowerShell).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗