[BUG]  "Error: String to replace not found in file."

Resolved 💬 12 comments Opened May 5, 2025 by mrjoshuak Closed Jan 5, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API
  • Claude CLI version: 0.2.101 (Claude Code)
  • Operating System: macOS Sequoia 15.5
  • Terminal: iTerm2

Bug Description

Claude Code is unable to use the Update tool successfully. The error in the title is occurring on every single attempt to use the Update tool. 100% failure rate.

Steps to Reproduce

  1. Trigger the Update tool by any mechanism.

Expected Behavior

Given that Claude Code should always have a copy of the current code in the context when using an Update tool I would expect it to always be successful. I can't think of any case that one would expect an LLM to fail at string matching tasks given a working UTF-8 source code tokenizer.

Actual Behavior

I only ever get an error in response to the Update tool being called.

⏺ Update(../../node/graph_shader.go)…
  ⎿  Error: String to replace not found in file.

Additional Context

I am using go in most of my coding projects. Does Claude Code not use the on disk file content in the context? Perhaps Claude Code is relying on the idea that LLM output code remains unchanged when written to the file? If so this would fail to account for ecosystems like go in which source code might be reformatted on the fly. Claude Code should be careful to update its context with actual file content prior to every api call to insure that file content is quoted correctly accounting for external tool and user manipulation. But this is just my blind speculation as to a possible causes.

View original on GitHub ↗

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