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 to C:\Users\mike\source\repos\OPC

Steps to Reproduce

  1. Create a subst drive: subst S: C:\Users\mike\source\repos\OPC
  2. Navigate to a project on the subst drive
  3. Read a file using the Read tool
  4. Immediately attempt to Edit the same file
  5. 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:

  1. How Claude Code resolves/caches file paths on virtual drives
  2. Timestamp comparison between subst path and resolved real path
  3. Internal file modification detection mechanism

View original on GitHub ↗

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