Bug: Edit/Write tools fail with false positive errors on Windows Git Bash

Resolved 💬 3 comments Opened Dec 22, 2025 by tokincode Closed Dec 25, 2025

Bug Description

On Windows with Git Bash (MINGW64), the Edit and Write tools frequently fail with false positive errors, even when the file has not been modified by any external process.

Environment

  • Claude Code Version: 2.0.75
  • OS: Windows 10/11 with Git Bash (MINGW64_NT-10.0-26200)
  • Shell: Git Bash (MINGW64)

Symptoms

Error 1: "File has been unexpectedly modified"

After using Read tool, immediately using Edit fails with:

Error: File has been unexpectedly modified. Read it again before attempting to write it.

Error 2: "File has not been read yet"

Even after successfully reading a file with the Read tool, using Write fails with:

Error: File has not been read yet. Read it first before writing to it.

Reproduction Steps

  1. Open Claude Code in Git Bash on Windows
  2. Read a file: Read(C:\Users\username\.bashrc)
  3. Immediately try to edit or write to the same file
  4. Error occurs even though:
  • File was not modified by any external process
  • File modification timestamp remains unchanged
  • No other process is accessing the file

Investigation Results

  1. File not actually modified: Monitoring stat output shows the file mtime does not change between Read and Edit/Write attempts.
  1. No external process interference: Checked running processes - no file sync tools (OneDrive, Dropbox) or antivirus actively modifying the file.
  1. Path normalization issue suspected: Git Bash uses different path formats:
  • Git Bash style: /c/Users/username/.bashrc
  • Windows style: C:\Users\username\.bashrc
  • Mixed style: C:/Users/username/.bashrc

The tool may be tracking file state using different path representations, causing cache misses.

  1. Encoding issues observed: When reading the file, some content appeared with unusual spacing (possibly null bytes between characters), which could cause hash comparison failures.

Workaround

Using Bash tool with heredoc/cat command works correctly:

cat > ~/.bashrc << 'EOF'
# file content
EOF

Expected Behavior

  • Edit tool should work after Read tool without errors
  • Write tool should work after Read tool without errors
  • File state tracking should correctly normalize paths on Windows/Git Bash

Additional Context

This issue seems to be related to Windows Git Bash path handling. The internal file state tracking mechanism may need to:

  1. Normalize all paths to a consistent format before comparison
  2. Handle Git Bash (MSYS/MINGW) path translations correctly
  3. Possibly use file handles or inodes instead of path strings for tracking

View original on GitHub ↗

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