Crash When Attempting Empty File Write

Status Fixed / completed
Maintainer reply ✓ Yes — blois
Activity 10 comments · opened Jun 23, 2025 · closed Jun 25, 2025
💡 Likely answer: A maintainer (blois, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
when claude-code tries to create an empty file, it crashes.

steps to reproduce: ask claude to create an empty file

error

> i think you have a bug in your system. can you help me isolate the issue by creating 
  an empty file called test.txt at the root of cwd?

✻ Thinking…

  The user is asking me to create an empty file called test.txt at the root of the 
  current working directory to help isolate a bug. This is a straightforward request 
  for troubleshooting purposes. I should use the Write tool to create an empty file at 
  the path test.txt.

⏺ Write(test.txt)

╭──────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                          │
│  Opened changes in Visual Studio Code ⧉                                                  │
│  Save file to continue…                                                                  │
│                                                                                          │
│ Do you want to make this edit to test.txt?                                               │
│ ❯ 1. Yes                                                                                 │
│   2. Yes, and don't ask again this session (shift+tab)                                   │
│   3. No, and tell Claude what to do differently (esc)                                    │
│                                                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────╯


node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: String not found in file. Failed to apply edit.
    at gO (file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1720:546)
    at nF5 (file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1979:9834)
    at F (file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1979:8812)
    at file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1979:9078
    at GI (file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:82:21374)
    at VY (file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:82:40861)
    at file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:82:39057
    at vP1 (file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:76:79278)
    at Immediate.SP1 [as _onImmediate] (file:///Users/charlotte.zhuang/.nvm/versions/node/v20.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:76:79696)
    at process.processImmediate (node:internal/timers:478:21)

Node.js v20.11.0

Environment Info

  • Platform: darwin
  • Terminal: vscode
  • Version: 1.0.31
  • Feedback ID: 8e687528-2465-44a6-8ef4-fccaecca276b

Errors

Note: Error logs were truncated.

View original on GitHub ↗

10 Comments

elkhayyat · 1 year ago

facing this issue too

casepot · 1 year ago

Happening to me too. Seems to be only in VSCode?

admmoises · 1 year ago

Me too

marty0678 · 1 year ago

The same issue occurs in WSL too - particularly an issue when attempting to create __init__.py files as part of a larger process, as it will crash mid-progress.

xshapira · 1 year ago

This might be related to #2300

xshapira · 1 year ago
Happening to me too. Seems to be only in VSCode?

Just checked, it’s happening in Cursor too.

blois collaborator · 1 year ago

Thanks for the report, a fix should be arriving soon.

xshapira · 1 year ago

@blois the current version is 1.0.51 and we're still having this issue.

It also happens when claude attempts to edit .md files - see #2300

We'd appreciate a fix because the only workaround for now is running in "YOLO" mode.

scottrfrancis · 1 year ago

driving me crazy... does creating the file with some de minimus content first help?

github-actions[bot] · 1 year ago

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.