[BUG] Claude Code + Visual Studio Code throwing error on diff
Environment
- Platform (select one): Anthropic API
- Claude CLI version: 1.0.0
- Operating System: Windows 11
- Terminal: Visual Studio Code + WSL
Bug Description
Everytime Claude Code wants to edit a file, it will throw the following error in the terminal - probably because of the visual studio code plugin / diff viewer. I would like to see the changes in visual studio code.
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: Error: String not found in file. Failed to apply edit. at gm (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1530:518) at S25 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:8393) at J (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7717) at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7952 at f7 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:21374) at gZ (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:40861) at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:39057 at Iy1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:155632) at Immediate.rj1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:156050) at process.processImmediate (node:internal/timers:476:21)
Steps to Reproduce
- Will happen on every edit / diff.
Expected Behavior
Showing diff / line changes
A fix will be coming to address where this happens periodically, but it is unexpected that it happens for every edit. Can you confirm that this is indeed every edit?
A fix will be coming to address where this happens periodically, but it is unexpected that it happens for every edit. Can you confirm that this is indeed every edit?
I just updated to Claude Code 1.0.2 and unfortunately the issue seems to be still here. I changed about 10 CSS files, no issues, but when asking to update the README.md I am still getting the error:
Opened changes in Visual Studio Code ⧉ │ │ Save file to continue… │ │ │ │ Do you want to make this edit to README.md? │ │ ❯ 1. Yes │ │ 2. Yes, and don't ask again this session (shift+tab) │ │ 3. No, and tell Claude what to do differently (esc) │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: Error: String not found in file. Failed to apply edit. at mm (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1530:518) at _25 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:8755) at J (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7717) at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7952 at f7 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:21374) at gZ (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:40861) at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:39057 at Gy1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:155632) at Immediate.oj1 [as _onImmediate] (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:156050) at process.processImmediate (node:internal/timers:476:21)
I am also getting this bug a lot. I will get it for both sonnet and opus, same setup as OP.
I appear to get it when its trying to do a larger diff, if i ask it to make a small change it will be fine, I believe its when it tries to do a large diff is when it fails
Actually, i've had it happen on files now that were also short, perhaps the issue happens more often in longer context windows? I'm not sure what the cause is but it seems to be getting more frequent and is blocking me from completing large changes as i dont want to blindly accept a change
Same here, I'm getting this error message on every single edit when in VSCode (WSL2, Ubuntu 24.04). In Windows Terminal, Claude Code works just perfectly.
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: Error: String not found in file. Failed to apply edit. at mm (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1468:518) at N25 (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1837:9445) at J (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1837:8407) at file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1837:8642 at b7 (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:150:21374) at hZ (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:150:40861) at file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:150:39057 at Qy1 (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:144:155632) at Immediate.sj1 [as _onImmediate] (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:144:156050) at process.processImmediate (node:internal/timers:485:21)
Happening for me as well running clade code via wsl distro in vs code
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: Error: String not found in file. Failed to apply edit. at mm (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1468:518) at N25 (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1837:9445) at J (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1837:8407) at file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1837:8642 at b7 (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:21374) at hZ (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:40861) at file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:39057 at Qy1 (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:155632) at Immediate.sj1 [as _onImmediate] (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:156050) at process.processImmediate (node:internal/timers:491:21)
I'm going to cancel max subscription after this month ... vs code integration is so unstable on wsl
As a status update, we're actively working to fix the WSL integration in the coming updates. Please stay tuned!
@tim-basic what version of claude are you hitting this with (claude --version)
@tim-basic what version of claude are you hitting this with (claude --version)
@igorkofman prints out 1.0.3 (Claude Code)
Thanks for jumping on this :)
Please update to latest (claude update). This should be significantly less common now and we'll have a fix that full resolves it early next week. Thanks for the report.
Thanks - I thought I did a fresh install 2 days ago. Just updated now. Will let you know if it continues.
Was using claude code 1.0.6 last night for 4 hours and didn't see the bug appear. @igorkofman
It's happening on every new file for me - using Node 22.16.0 with Claude Code 1.0.33 with WSL.
Not sure if this will work for you but I uninstalled the extension and installed from scratch and that resolved the issue for me. @marty0678
Not sure if this will work for you but I uninstalled the extension and installed from scratch and that resolved the issue for me. @marty0678
Thanks @tim-basic but no luck. Before I posted I also set up a new nvm of the latest Node 22 LTS and installed it there and same issue.
Just tried logging out and re-installing it fresh again from that node instance and does the same thing once it tries to make a new file.
Interesting hmm @marty0678
I'm using the following with no issues:
Node version: v22.14.0
Claude Code VS Code extension version: 1.0.33 (server version: 1.0.31)
WSL version: 2.5.9.0
I woke up to this error with no updates in my systems through the night; been using latest Claude and Intellij.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.