[BUG] Write tool fails with EEXIST when parent directory already exists (Windows)

Resolved 💬 2 comments Opened Mar 9, 2026 by nv186000 Closed Apr 6, 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?

The Write tool fails when trying to create a new file inside an existing directory. It throws EEXIST because it unconditionally tries to mkdir the parent directory, even when it already exists.

What Should Happen?

Writing a new file into an existing directory should succeed. The tool should use mkdir -p (or { recursive: true }) so it is a no-op when the directory already exists.

Error Messages/Logs

EEXIST: file already exists, mkdir 'C:\Users\navee\OneDrive\Documents\swedish\docs'

Steps to Reproduce

Steps to Reproduce

Have an existing project directory, e.g. C:\Users\navee\project\docs\
Ask Claude to write a new file into it: docs\product-backlog.md
The Write tool is called with path C:\Users\navee\project\docs\product-backlog.md
Tool fails immediately — file is never created

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Latest

Platform

Other

Operating System

Windows

Terminal/Shell

Other

Additional Information

The bug only affects existing directories. Writing to a brand new directory path (one that does not exist yet) works fine because then mkdir has something to do. This makes the bug hard to notice on first use of a project, but it blocks every subsequent file write into any established folder structure.

View original on GitHub ↗

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