[BUG] Edit and Write tools fail with EEXIST. Msg: "Both Write and Edit tools fail on this machine for existing directories."

Resolved 💬 2 comments Opened Mar 5, 2026 by R-W-C Closed Mar 5, 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 Edit and Write tools fail with EEXIST: file already exists, mkdir 'H:\PHP_root\DeneyeScreenerClient' when targeting any file in the project root directory (e.g. sw.js). Neither tool writes anything — the operation is silently aborted. This happens consistently on Windows 11 with a project root at a non-standard drive path (H:\...). The Read tool works fine.

What Should Happen?

Edit and Write should successfully modify files in the project root directory. The internal mkdir call that ensures parent directories exist should use the recursive: true option (i.e. fs.mkdirSync(dir, { recursive: true })), which is a no-op when the directory already exists rather than throwing EEXIST.

Error Messages/Logs

EEXIST: file already exists, mkdir 'H:\PHP_root\DeneyeScreenerClient'                                                      
This error appears in the Claude Code UI as the tool result for both the Edit and Write tools.

Steps to Reproduce

  1. Open a project where the working directory is a non-C: drive path (e.g. H:\PHP_root\DeneyeScreenerClient)
  2. Ask Claude to edit any file located directly in the project root (e.g. sw.js, index.html) — not in a subdirectory
  3. Claude calls the Edit or Write tool with the full path (e.g. H:\PHP_root\DeneyeScreenerClient\sw.js)
  4. The tool fails immediately with EEXIST: file already exists, mkdir 'H:\PHP_root\DeneyeScreenerClient'
  5. The file is not modified

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude Code CLI — model: claude-sonnet-4-6

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

  • The failure occurs for files in the project root only. Files in subdirectories (e.g. assets/js/core/App.js) may or may

not be affected — not tested exhaustively.

  • The Read tool works correctly on all paths.
  • The Bash tool works correctly, and Node.js fs.writeFileSync / fs.readFileSync write and read files at the same paths

without issue — confirming it is not a filesystem permissions problem.

  • The error message says mkdir 'H:\PHP_root\DeneyeScreenerClient' — the project root itself — which suggests the tool is calling mkdir on the parent of the target file. For a file at the root level, the parent is the project root (which already exists), triggering the error.
  • The issue is consistently reproducible across the entire session; it is not transient.

Note: All information I filled in, is directly coming from Claude Code itself.

View original on GitHub ↗

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