[BUG] Edit tool fails with EEXIST when editing files at the working directory root on Windows
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?
Description
The Edit tool throws EEXIST: file already exists, mkdir 'C:\Users\<user>\<project>' when editing any file whose parent directory is the current working directory (cwd). Files in subdirectories of the cwd work fine.
EEXIST: file already exists, mkdir 'C:\Users\Andre\Obsidian'
Edit a file in a subdirectory: Edit c:\Users\Andre\Obsidian\Context\LEARNINGS.md — works fine
Expected behavior
Edit should succeed for files at any depth, including files whose parent directory is the cwd.
Actual behavior
Edit fails with EEXIST — the internal mkdir call tries to create the cwd directory, which already exists.
Environment
Windows 11 Home 10.0.26200
Claude Code via VS Code extension
Shell: bash (Git Bash)
Workaround
Use sed -i via Bash tool for files at the cwd root.
What Should Happen?
The Edit tool should successfully edit files whose parent directory is the current working directory, just as it does for files in subdirectories. The internal mkdir for the parent directory should handle the case where the directory already exists (e.g., use mkdir -p equivalent or check existence first).
Error Messages/Logs
EEXIST: file already exists, mkdir 'C:\Users\Andre\Obsidian'
That's the full error message the Edit tool returns when attempting to edit any file at the cwd root (e.g., STATUS.md, Tasks-personal.md).
Steps to Reproduce
Steps to reproduce
Open Claude Code with cwd = C:\Users\Andre\Obsidian
Read a file at the cwd root: Read c:\Users\Andre\Obsidian\STATUS.md — works
Edit that file: Edit c:\Users\Andre\Obsidian\STATUS.md — fails with:
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.69
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗