[BUG] Bash tool fails with EEXIST on all calls after the first within a single session (Windows, session-env mkdir race)

Resolved 💬 3 comments Opened Apr 19, 2026 by vrp18group Closed Apr 22, 2026

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?

This is a bug in Claude Code's bash harness — it uses mkdir instead of mkdir -p when creating the session directory, so the second bash call in any session always fails. Clearing stale lock files helped bootstrap but doesn't fix the underlying harness behavior.
This is not something you can fix by deleting files. It needs to be fixed at the Claude Code application level.

OS: Windows 11
Claude Code version: check via claude --version in PowerShell
Reproduction: any session with 2+ sequential bash tool calls fails on the second call with EEXIST on the session UUID directory under C:\Users\<user>\.claude\session-env\<session-uuid>
Root cause (observed): harness uses mkdir instead of mkdir -p when creating the session working directory, so the second call in the same session always fails
Workaround: chain all commands into a single bash invocation using &&
Clearing session-env contents fixes the bootstrap issue but not the within-session recurrence

What Should Happen?

Each bash tool call within a session should execute successfully regardless of how many previous bash calls have occurred in the same session. The session working directory should be created once at session start and reused for all subsequent calls, or the creation should use mkdir -p (create-if-not-exists) so repeated calls do not error.

Error Messages/Logs

Steps to Reproduce

  1. Open Claude Code on Windows with a project loaded
  2. Ask Claude Code to run any bash command — e.g. echo "first call". This succeeds.
  3. In the same session, ask Claude Code to run any second bash command — e.g. echo "second call". This fails immediately with EEXIST.
  4. Inspect C:\Users\<username>\.claude\session-env\<session-uuid>\ — the directory was created by step 2, and step 3 attempts to mkdir it again instead of reusing it.
  5. Workaround confirmed: chaining both commands in a single bash call (echo "first" && echo "second") succeeds because only one mkdir is attempted.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.111

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗