[BUG] Error: Found 2 matches of the string to replace, but replace_all is false.
I get this red colored error happen a lot. Is there something I need to do to fix this?
● Update(run.py)
⎿ Error: Found 2 matches of the string to replace, but replace_all is false. To replace all occurrences, set replace_all to true. To replace only one occurrence, please
provide more context to uniquely identify the instance.
String: <string here>
I would expect Claude to recover itself from this, it happens when the file is large or contains many lines of code that are similar to each other. Claude will try to Read more of the file and adjust its Update request to correctly identify the specific piece of code to change, but it may struggle if there are many pieces that are similar or identical.
For ways you could help Claude, consider breaking your code into multiple files that contain unique behaviour. You could even ask Claude to identify parts of the code that seem duplicated in functionality, or literal code, that could be safely modularised.
+1
+1
My Claude was trying to find and replace a set of strings in a file, so it tried and failed to use MultiEdit twice before giving up and resorting to sed instead:
✻ Thinking…
Let me fix all the occurrences of asyncRenderString in this test file. I'll use MultiEdit to make all the changes at
once:
● Update(__tests__/general/formTest.js)
⎿ Error: Found 2 matches of the string to replace, but replace_all is false. To replace all occurrences, set
replace_all to true. To replace only one occurrence, please provide more context to uniquely identify the
instance.
String: it("logs an error if path isn't an array.", async function () {
✻ Thinking…
Let me fix this by being more specific about the instances:
● Update(__tests__/general/formTest.js)
⎿ Error: Found 2 matches of the string to replace, but replace_all is false. To replace all occurrences, set
replace_all to true. To replace only one occurrence, please provide more context to uniquely identify the
instance.
String: it("Works with multiple forms", async function () {
✻ Thinking…
Let me run the tests to see if we have the issue fixed with what we've changed so far. I'll need to make sure all
the async related changes are done:
● Bash(sed -i 's/await nunjucks\.asyncRenderString/nunjucks.renderString/g'
/workspace/apps/__tests__/general/formTest.js)
⎿ Running…
+1
+1
+1
+1
+1
+1 it recovered but it would be nice if was something we could enabled instead of claude code having to do 20+ different edits of the same thing
+1
+1
+1
I don't understand how anyone is using claude code when it literally does this multiple times a session. Is everyone "using" claude code just faking it? this is unusable in its current state.
You're telling me that of all AI products, Claude Code runs into literal errors doing multiple replacements?
Its entire purpose is editing files like this!
Is this a joke? Or are we doing something wrong? How does anyone actually use this tool if it constantly runs into issues with multiple replacements? Every basic AI coding tool out there can do this.
+1, but it will resume soon
No response, no resolution, nothing. Anthropic is an embarrassment. If Claude Code of all tools can't do multiple replacements without running into errors all the time then Anthropic is a pure fraud company.
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.
I left claude code because of this mess. Is this still a problem?
I left claude code because of this mess. Is this still a problem?
no @Th0rGarden