Edit/Write tools fail with EEXIST on Windows when parent directory exists

Resolved 💬 2 comments Opened Mar 19, 2026 by jordandakota Closed Apr 17, 2026

Bug Description

The Edit and Write tools fail on Windows with an EEXIST error when the target file's parent directory already exists. The tools appear to call mkdir (non-recursive) on the parent directory before writing, which throws when the directory is already present.

Error Message

EEXIST: file already exists, mkdir 'C:\users\jorda\downloads'

Steps to Reproduce

  1. On Windows 11, have Claude Code attempt to edit or write a file in an existing directory (e.g. C:\users\jorda\downloads\somefile.html)
  2. Use the Edit tool with a valid old_string/new_string, or the Write tool with content
  3. The operation fails with the EEXIST error above

Expected Behavior

Edit/Write should succeed since the parent directory already exists. The mkdir call should either use { recursive: true } (which is a no-op for existing directories) or check for directory existence before calling mkdir.

Observed Behavior

  • Read tool works fine with the same path
  • Edit tool fails with EEXIST
  • Write tool fails with EEXIST
  • Workaround: use Bash with Python/sed to modify files instead

Environment

  • OS: Windows 11 Home 10.0.26200
  • Shell: bash (Git Bash)
  • Model: Claude Opus 4.6

Workaround

Writing files via python -c or sed through the Bash tool works without issue.

View original on GitHub ↗

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