Edit tool fails with 'File has been unexpectedly modified' on Windows subst drives
Resolved 💬 3 comments Opened Dec 23, 2025 by trust11 Closed Dec 26, 2025
Description
The Edit tool frequently fails with the error "File has been unexpectedly modified" even when no external process is modifying the file. This happens specifically on Windows with subst virtual drives.
Environment
- OS: Windows 11
- Claude Code Version: Latest (as of 2025-12-23)
- Drive Setup:
S:is a subst drive mapping toC:\Users\mike\source\repos\OPC
Steps to Reproduce
- Create a subst drive:
subst S: C:\Users\mike\source\repos\OPC - Navigate to a project on the subst drive
- Read a file using the Read tool
- Immediately attempt to Edit the same file
- Error occurs: "File has been unexpectedly modified"
Investigation Results
I verified that no external process is modifying the files:
# Monitoring file for 5 seconds
$hash1 = (Get-FileHash $file).Hash # 8E4725FA39B3F238...
Start-Sleep -Seconds 5
$hash2 = (Get-FileHash $file).Hash # 8E4725FA39B3F238...
# Result: Content unchanged, Timestamp unchanged
Checked for potential culprits:
- No IDE running (devenv, Rider, VS Code)
- OneDrive running but project NOT in OneDrive folder
- No file watchers (fswatch, watchman)
- Git fsmonitor not configured
- Only background MSBuild node processes (not actively modifying files)
Compared subst path vs real path:
Subst: S:\OPC-Feature\BexioSyncService\Worker.cs
Real: C:\Users\mike\source\repos\OPC\OPC-Feature\BexioSyncService\Worker.cs
LastWriteTime: Identical on both paths
Workaround
Using PowerShell to perform edits works reliably:
$content = Get-Content 'file.cs' -Raw
$content = $content -replace 'old', 'new'
Set-Content 'file.cs' -Value $content -NoNewline
Expected Behavior
The Edit tool should successfully modify files on subst drives when no external modifications have occurred.
Possible Cause
The issue might be related to:
- How Claude Code resolves/caches file paths on virtual drives
- Timestamp comparison between subst path and resolved real path
- Internal file modification detection mechanism
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗