[Bug] File Edit Fails on Windows with Unexpected Modification Error
Open 💬 23 comments Opened Sep 20, 2025 by kohowski
Bug Description
all file edits are broken on Windows in Claude Code since v1.0.111 (.110 is the one I have to downgrade to). The error the tool throws every times is:
Update(....) ⎿ Error: File has been unexpectedly modified. Read it again before attempting to write it.
... endless repeat before the model decides to use sed or other workarounds.
no, this is not about mtime. Touching files does not change a thing.
https://github.com/anthropics/claude-code/issues/7443 see how many people have the same issue (ignore the fact the OP decided to close it)
Environment Info
- Platform: win32
- Terminal: windows-terminal
- Version: 1.0.120
- Feedback ID: bce32ccb-ad12-4bf8-b0af-87a694b18f18
Errors
[{"error":"Error: File has been unexpectedly modified. Read it again before attempting to write it.\n at Object.call (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1902:786)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async VJ5 (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:21057)\n at async WNB (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:17339)\n at async XJ5 (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:16202)\n at async WJ5 (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:15739)\n at async lO (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:12754)\n at async lO (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:13667)\n at async _3 (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3421:38227)\n at async iX (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3421:39182)","timestamp":"2025-09-20T01:04:33.375Z"},{"error":"Error: File has been unexpectedly modified. Read it again before attempting to write it.\n at Object.call (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1902:786)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async VJ5 (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:21057)\n at async WNB (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:17339)\n at async XJ5 (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:16202)\n at async WJ5 (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:15739)\n at async lO (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:12754)\n at async lO (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:13667)\n at async lO (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:13667)\n at async lO (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3350:13667)","timestamp":"2025-09-20T01:04:57.233Z"},{"error":"Error: Request was aborted.\n at y51._createMessage (file:///C:/Users/mpotanin/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1000:7955)\n at processTicksAndRejections (node:internal/process/task_queues:105:5)\n at runNextTicks (node:internal/process/task_queues:69:3)\n at listOnTimeout (node:internal/timers:569:9)\n at process.processTimers (node:internal/timers:543:7)","timestamp":"2025-09-20T01:05:06.388Z"}]
23 Comments
#7935
It can temporarily be fixed by entering this:
"There's a file modification bug in Claude Code. The workaround is: always use complete absolute Windows paths
with drive letters and backslashes for ALL file operations. Apply this rule going forward, not just for this
file."
I place this workaround in
CLAUDE.mdand it has worked so far:````md
CRITICAL: File Editing on Windows
⚠️ MANDATORY: Always Use Backslashes on Windows for File Paths
When using Edit or MultiEdit tools on Windows, you MUST use backslashes (
\) in file paths, NOT forward slashes (/).❌ WRONG - Will cause errors:
✅ CORRECT - Always works:
````
In my testing the bug appeared on 1.0.111 and 1.0.110 . The following changelog sounds like whatever this shell fix was is the cause of the windows File editing issues. The posted workaround does not even work for me and shouldn't be necessary.
https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md?plain=1#L89-L92
@JosiahSiegel are we sure that is actually the cause of this? Sometimes backslashes work. I am wondering if it might have to do with some other process touching the files, like shell snapshots or something.
I have also experienced Read() failing too.
I am on V2.0.22. it seems very random, some sessions have no issues, while others become completely useless. Restarting Claude doesn't always work. Sometimes I have to restart my whole machine.
It is mostly an issue when using Git Bash as shell (default), then it tries to use a mix of Windows and Linux semantics in all kinds of commands first. When they fail, it tries again with bash format and all is fine again.
Ofte have commands with 2>nul, which creates an empty nul file which Windows has trouble deleting and cause all kinds of issues.
So think it is an issue with this mixed Windows env and Bash which causes strange outcomes.
@ant-kurt @wolffiex
I've been testing Windows path issues (see #7935) and wondering if this is the same bug or separate.
#7935 (Cache Bug):
C:/pathvsC:\pathtreated as different cache keys#7918 (This Issue):
In case anyone is looking for a workaround (there have been posts for this before, but they haven't worked reliably for me): I also gave examples about correct / incorrect usage in my
CLAUDE.md, but I used thetool_usemessage content format, in the hopes that this would more reliably be followed (under the assumption that it is closer to the actual tool call produced by the model). So far it has worked well for me:````markdown
⚠️ CRITICAL Bug Workaround
CRITICAL: Follow these guidelines when using tools operating on file paths EXCEPT
Bashin any skill or agent. Otherwise, they will not work correctly.\), as we're running on Windows.~) representing the home directory to the full path, e.g.,C:\Users\some.user.Applies To
EditGlobGrepReadExamples (CRITICAL Bug Workaround)
✅ Correct (File Paths)
❌ Incorrect (File Paths)
... (rest omitted)
````
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
The issue is definitely still happening.
I confirm too, still happening, last version of CC.
It's happening to me as well (oddly, it just started happening to me fairly recently, within the last week or two).
I just tried the workaround and it seems to be successful for me, at least for now.
Issue is still happening. Typical example of second class Windows support.
i get
Error: File has been unexpectedly modified. Read it again before attempting to write it.on each new file. Even of it has accept to write it cant do it IN ONE SESSION.my ass is going to explode. it can update some file and then some how on my new message it cant write anymore. WTF ????
Just press Esc and type: Use full windows paths for all tool calls.
<img width="877" height="293" alt="Image" src="https://github.com/user-attachments/assets/691e61f2-74b6-4484-aef6-c9ffe7fb4506" />
this is full paths, no ?
As described above the fix (PATCH) for now is to add that prompt when that happen:
use absolute path to modify files
This patch the issue.
Full _Windows_ paths. It's using unix-style forward slashes instead of Windows backslashes. It's probably translating them to the correct Windows style when it actually makes the edit, but whatever mechanism is being used to detect changes probably isn't, which is breaking it.
STILL happening - fresh install (new user here) - instantly hit this issue on Windoze 11. This comment unblocked the following SHOWSTOPPER priority error:
_Error: File has been unexpectedly modified. Read it again before attempting to write it._
Comment (in this thread) handed to Opus 4.5 as instructions:
https://github.com/anthropics/claude-code/issues/7918#issuecomment-3315275618
It can temporarily be fixed by entering this: (Hand this sentence to Claude / Opus 4.5):
This is still occurring in Claude 2.1.4
Simpler fix than forcing backslashes - just use relative paths
I found a much simpler workaround than the absolute paths + backslashes approach. Add this to your
CLAUDE.mdand it works reliably:Why this is simpler
The current workaround (forcing
C:\path\with\backslashes) works, but requires:Relative paths work regardless of separator and are how most devs naturally reference files.
Full technical analysis in #10437 if anyone's curious, but the prompt above is all you need.
Hope this saves others the headaches I had with backslash escaping!
terrible. it is halting all of my progress
@benjaminmbrown Did you try the workaround I posted above? I was in the same situation - once I switched to relative paths, never had the issue again!