EEXIST: file already exists on every second Bash tool call (Windows)

Resolved 💬 2 comments Opened Apr 17, 2026 by erwindr67 Closed Apr 18, 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?

When using the Bash tool in Claude Code on Windows, the first call in a session succeeds. Every subsequent call fails with:

EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\session-env\<session-id>'

The directory is created on the first call but never cleaned up. Subsequent calls try to create the same directory again and fail.

What Should Happen?

Consecutive Bash calls should work without manual intervention. On Linux/Mac this appears to work correctly, suggesting the mkdir call does not handle EEXIST gracefully on Windows.

Error Messages/Logs

EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\session-env\<session-id>'

Steps to Reproduce

  1. Run any Bash command (e.g. echo test)
  2. Run a second Bash command in the same session
  3. Second call fails with EEXIST

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude Code 2.1.98

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

Workaround
Manually delete C:\Users\<user>\.claude\session-env\<session-id>\ before each Bash call.
The directory is always empty.

View original on GitHub ↗

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