claude-code - 💡(How to fix) Fix [BUG] Bash tool wedges mid-session with `EEXIST: mkdir session-env/<UUID>` and never recovers [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54779Fetched 2026-04-30 06:36:16
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×5commented ×2closed ×1unlabeled ×1

The Bash tool enters an unrecoverable error state mid-session when it attempts to create its own already-existing session-env directory. Every subsequent Bash call for the remainder of the session returns the same EEXIST error.

Error Message

EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\session-env\89580c33-6e44-49e5-b165-291f9efaab08'

Root Cause

The Bash tool enters an unrecoverable error state mid-session when it attempts to create its own already-existing session-env directory. Every subsequent Bash call for the remainder of the session returns the same EEXIST error.

Fix Action

Workaround

Delete C:\Users\<user>\.claude\session-env\<UUID> to clear the wedge. This is impractical from inside Claude Code (the only tool that could run rmdir is the Bash tool that is wedged). Workaround currently requires exiting the session or using a separate terminal.

Code Example

EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\session-env\89580c33-6e44-49e5-b165-291f9efaab08'

---
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

Summary

The Bash tool enters an unrecoverable error state mid-session when it attempts to create its own already-existing session-env directory. Every subsequent Bash call for the remainder of the session returns the same EEXIST error.

Environment

  • Platform: Windows 11 Enterprise 10.0.26200
  • Shell: Git Bash (MSYS2 / MinGW64)
  • Claude Code: CLI in terminal
  • User home: C:\Users\<user>
  • Session-env path: C:\Users\<user>\.claude\session-env\<UUID>

Error

EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\session-env\89580c33-6e44-49e5-b165-291f9efaab08'

Timeline (single session)

  1. Session started normally. session-env\<UUID> created successfully on startup.
  2. Many Bash tool calls worked over the course of several hours - including heavy ones (p4 operations, piped commands, multiple arguments).
  3. Approximately 5 minutes after a successful complex Bash call, a trivial call (echo "retry") returned the EEXIST error.
  4. Every subsequent Bash call - including echo hello - returned the identical error.
  5. The wedge persisted until the session was restarted.

Key observations

  • The session-env directory <UUID>/ is empty throughout. Listing its contents before and after the wedge shows no files written to it by Claude. It appears to be a bootstrap marker, not a working directory.
  • The wedge fires on the current session's own UUID - it is not a stale-directory-from-prior-session collision.
  • The directory genuinely does already exist (it is the one the current session created successfully at startup), so the EEXIST is correct from the OS's perspective. The bug is that the Bash tool treats mkdir non-idempotently and poisons the tool for the remainder of the session.
  • Other tools (Read, Edit, Grep, Glob, Write, MCP tools) continued working normally while Bash was wedged.

What Should Happen?

mkdir of the session-env directory should be idempotent. If the directory already exists, proceed normally. The Bash tool should not cache a terminal failure state that persists for the rest of the session.

Suggested fix directions (for Anthropic's triage)

  1. Make the session-env setup use mkdir -p semantics / fs.mkdir(recursive: true) and treat EEXIST as success.
  2. If the directory check is intentionally non-recursive, gate the mkdir on a pre-existence check (if not exists -> mkdir).
  3. Decouple tool-call error state from session-env setup so a transient setup issue doesn't wedge Bash for the rest of the session.

Additional context

A related but distinct issue was filed as #31233 (Write/Edit tool EEXIST on Windows NTFS with symlinked .claude/). That affects a different tool and a different .claude/ subpath; this report is specifically about the Bash tool and session-env/.

Workaround

Delete C:\Users\<user>\.claude\session-env\<UUID> to clear the wedge. This is impractical from inside Claude Code (the only tool that could run rmdir is the Bash tool that is wedged). Workaround currently requires exiting the session or using a separate terminal.

Error Messages/Logs

Steps to Reproduce

Inconsistent repro. Seems to occur more frequently with multiple sessions running concurrently, but that is not always the case. Have had it happen in both CLI and also in VSCode extension.

There's no consistency in terms of what specific command(s) trigger the wedging. Only obvious thing is that the more bash calls that happen the more likely it is that the bug occurs.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.123

Platform

AWS Bedrock

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

No response

extent analysis

TL;DR

The Bash tool can be fixed by making the session-env setup use mkdir -p semantics to treat EEXIST as success, allowing the tool to proceed normally even if the directory already exists.

Guidance

  • Verify that the issue is indeed caused by the non-idempotent mkdir operation by checking the error message and the existence of the session-env directory.
  • Consider implementing a pre-existence check before attempting to create the session-env directory to avoid the EEXIST error.
  • Decouple the tool-call error state from the session-env setup to prevent a transient setup issue from wedging the Bash tool for the rest of the session.
  • As a temporary workaround, deleting the session-env directory can clear the wedge, but this requires exiting the session or using a separate terminal.

Example

# Using mkdir -p to create the session-env directory
mkdir -p C:\Users\<user>\.claude\session-env\<UUID>

Notes

The issue seems to be specific to the Bash tool and the session-env/ subpath, and is not related to the Write/Edit tool issue reported in #31233. The cause of the issue is likely due to the non-idempotent mkdir operation, and making it idempotent should fix the problem.

Recommendation

Apply the workaround of using mkdir -p semantics to treat EEXIST as success, as this is a straightforward and effective solution to the problem. This change should be made to the session-env setup code to ensure that the Bash tool can proceed normally even if the directory already exists.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Bash tool wedges mid-session with `EEXIST: mkdir session-env/<UUID>` and never recovers [2 comments, 3 participants]