File Edit Failure: String Not Found in Empty File

Resolved 💬 3 comments Opened Jul 12, 2025 by AstroMined Closed Nov 30, 2025

Bug Description
Claude Code was trying to edit my .env file in a Python project and abruptly exited with this traceback below:\
● Bash(cp .env.example .env)
⎿ (No content)

● I need to create the .env file. Let me do that now:

● Write(.env)
⎿ Running hook PreToolUse:Write...

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Opened changes in Visual Studio Code ⧉ │
│ Save file to continue… │
│ │
│ Do you want to make this edit to .env? │
│ ❯ 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:391
triggerUncaughtException(err, true / fromPromise /);
^

Error: String not found in file. Failed to apply edit.
at uT (file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1636:728)
at iR6 (file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1969:12134)
at J (file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1969:11112)
at file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1969:11378
at hD (file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:21377)
at oF (file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:40875)
at file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:39071
at KT1 (file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:61:78877)
at Immediate.FT1 [as _onImmediate] (file:///home/astromined/.nvm/versions/node/v20.15.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:61:79295)
at process.processImmediate (node:internal/timers:478:21)

Node.js v20.15.0
astromined@llm:/code/Agent-MCP$

Environment Info

  • Platform: linux
  • Terminal: vscode
  • Version: 1.0.51
  • Feedback ID: 3c9aefcc-7531-4e4f-85da-867dd2524890

Errors

Note: Error logs were truncated.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗