Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Aider error

Aider: SearchReplaceNoExactMatch: This SEARCH block failed to exactly match...

Error message
SearchReplaceNoExactMatch: This SEARCH block failed to exactly match lines in {path}

Status: WorkaroundLast verified 2 documented fixes2 sources

What it means

In the diff (SEARCH/REPLACE) edit format, the SEARCH section the model sent does not match the current contents of the file, so that block was not applied. Aider's message says: "The SEARCH section must exactly match an existing block of lines including all white space, comments, indentation, docstrings, etc". It may add "Did you mean to match some of these actual lines from {path}?" or "Are you sure you need this SEARCH/REPLACE block? The REPLACE lines are already in {path}!". This is a form of the edit-format failure, and aider sends the message back to the model so it can resend only the failed blocks.

Causes

  • The model's SEARCH text differs from the file (whitespace, comments, indentation, docstrings), per aider's own error text in editblock_coder.py.
  • The REPLACE lines are already present in the file, so the SEARCH text no longer exists.
  • The same root causes listed in the File editing problems doc: the model not following the edit format, too much context, or a weak or quantized model.

How to fix it

  1. Fix 1.

    Follow the File editing problems doc: reduce context with /drop and /clear, use a more capable model, or switch edit formats.

    Terminal
    aider --edit-format whole
  2. Fix 2.

    Use architect mode so a separate editor model handles the file edits.

    Terminal
    aider --architect

More Aider errors

All 17 Aider errors

FAQ

What does "SearchReplaceNoExactMatch: This SEARCH block failed to exactly match..." mean in Aider?

In the diff (SEARCH/REPLACE) edit format, the SEARCH section the model sent does not match the current contents of the file, so that block was not applied. Aider's message says: "The SEARCH section must exactly match an existing block of lines including all white space, comments, indentation, docstrings, etc". It may add "Did you mean to match some of these actual lines from {path}?" or "Are you sure you need this SEARCH/REPLACE block? The REPLACE lines are already in {path}!". This is a form of the edit-format failure, and aider sends the message back to the model so it can resend only the failed blocks.

How do I fix "SearchReplaceNoExactMatch: This SEARCH block failed to exactly match..."?

There are 2 documented fixes. Start with the first: Follow the File editing problems doc: reduce context with /drop and /clear, use a more capable model, or switch edit formats.

Is this Aider error fixed?

Status: Workaround. No release removes the cause. The documented fixes work around it. Affected versions: All versions that use the diff (SEARCH/REPLACE) edit format.

Sources

Last verified against 2 sources: official docs, maintainer replies and release notes.

Newsletter

Fixes for the tools you use, weekly

One email per week. New coding agent releases, what broke, and how developers are working around it.