Roo-Code: Unable to apply diff to file - contents are out of sync

Which API Provider are you using?

Google Gemini

Which Model are you using?

gemini-2.0-flash-exp

What happened?

First off, outstanding piece of software. This is hands down the best AI codign experiecne I’ve had. Just discovered you after using the frustration that is windsurf, and man this is like a breath of fresh air, not to mention how accurate it is. So well done, keep up the good work. I’ll contribute if I can, or maybe you should start a donation fund. I’d happily sling you some $$

So…

I don’t think it’s model specific, but if I have updated a file directly it gets this error and goes into a loop trying to read it. If it’s trying to edit and it gets the error, eventually it decides to not use the diffs and write the whole file which gets it out of the loop, but reading doesn’t seem to have a mechanism for this.

Unable to apply diff to file - contents are out of sync

I apologise I’m not 100% sure this is just edited files, maybe just large files, but definitley seems to be to do with handling the diff editing option. I’ve certainly thought, “hang on I haven’t even looked at that file.”

It’ll do about 3-5 loops then say

"It seems like I’m still having trouble applying the diff to the design-system.md file. I will try using write_to_file to overwrite the entire file with the updated content, similar to what I did with the README.md file earlier.

First, I need to read the file content again to make sure I have the latest version."

then goes back into the same loop while it tries to read the file again

Steps to reproduce

  1. edit a file while you’re in an active flow/chat
  2. ask it to update that file

Relevant API REQUEST output

apply_diff for 'docs/design/frontend/design-system.md'] Result:

Error applying diff to file: /Users/fridaystreet/dev/docs/design/frontend/design-system.md - contents are out of sync. Try re-reading the relevant lines of the file and applying the diff again.

<environment_details>
# VSCode Visible Files
(No visible files)

# VSCode Open Tabs
(No open tabs)
</environment_details>

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18

Commits related to this issue

Most upvoted comments

@mrubens Looks like it’s still happening. not sure if you want to re-opne thi sor for me to create a new issue?

Interestingly this time I was using Gemini (not sure if that’s related), but it started out by just going straight to write_file to apply changes in stead of diff’ing. So obviously very slow. I said why aren’t you using diff and it said, oh yes that’s right i’ll use diff.

anyway it tried to use diff, hit the rror, and said itself. Oh because I’ve been using write_file the file is out of sync, I need to reread it. Then it just got in the loop again.

So attached is the extracted chat log. I have had to strip out the content etc in places re propriary code, but hopefully I haven’t lost the detail you need. if so i can send it to you privately.

cline_task_dec-16-2024_8-58-17-am.md

I did just merge https://github.com/RooVetGit/Roo-Cline/pull/120 and am releasing it as we speak in 2.2.8, so maybe that will help. I’ll look at your export though - thanks for that!