Aider-AI/aider · error · DiffError
UPDATE Error: File does not exist: {action.path}
Error message
UPDATE Error: File does not exist: {action.path} What it means
Application-time failure: an UPDATE action targets a file that does not exist on disk. Unlike DELETE (which warns and skips), UPDATE is strict — there is nothing to apply chunks against, so it raises and the whole apply is wrapped into a ValueError.
Source
Thrown at aider/coders/patch_coder.py:593
path_obj.parent.mkdir(parents=True, exist_ok=True)
# Ensure single trailing newline, matching reference behavior
content_to_write = action.new_content
if not content_to_write.endswith("\n"):
content_to_write += "\n"
self.io.write_text(full_path, content_to_write)
elif action.type == ActionType.DELETE:
self.io.tool_output(f"Deleting {action.path}")
if not path_obj.exists():
self.io.tool_warning(
f"DELETE Warning: File not found, skipping: {action.path}"
)
else:
path_obj.unlink()
elif action.type == ActionType.UPDATE:
if not path_obj.exists():
raise DiffError(f"UPDATE Error: File does not exist: {action.path}")
current_content = self.io.read_text(full_path)
if current_content is None:
# Should have been caught during parsing if file was needed
raise DiffError(f"Could not read file for UPDATE: {action.path}")
# Apply the update logic using the parsed chunks
new_content = self._apply_update(current_content, action, action.path)
target_full_path = (
self.abs_root_path(action.move_path) if action.move_path else full_path
)
target_path_obj = pathlib.Path(target_full_path)
if action.move_path:
self.io.tool_output(
f"Updating and moving {action.path} to {action.move_path}"
)View on GitHub (pinned to 5dc9490bb3)
Solutions
- Restore or recreate the file, or switch to the branch/worktree where it exists
- Fix the path in the patch to the actual file location
- If the intent is creating new content, change the action to '*** Add File:'
Example fix
# before *** Update File: renamed_module.py # after (file was renamed) *** Update File: src/renamed_module.py
Defensive patterns
Strategy: validation
Validate before calling
import os
def update_targets_exist(actions) -> list[str]:
return [a.path for a in actions
if a.type.name == "UPDATE" and not os.path.exists(os.path.join(ROOT, a.path))] Try / catch
try:
coder.apply_edits(edits)
except ValueError as e:
if "UPDATE Error: File does not exist" in str(e):
raise RuntimeError(f"file missing; check branch/worktree: {e}")
raise Prevention
- Verify the working tree/branch matches what the patch was generated against
- Check exact path spelling and case before applying
- Use Add (not Update) for files that should be created
When it happens
Trigger: File was deleted or renamed after the patch was parsed; UPDATE path has a typo/casing mismatch; patch generated against a branch where the file exists but applied in a worktree where it doesn't.
Common situations: git branch/worktree switches mid-session; files removed by another tool; case-sensitive filesystem exposing path casing bugs.
Related errors
- Delete File Error - file not found: {path}
- Could not find scope context:\n{scope_txt}
- Could not read file for UPDATE: {action.path}
- File referenced in patch not found: {rel_path}
- Delete File action missing path.
AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15).
Data as JSON: /api/errors/d957b04ccad2c94a.
Report an issue: GitHub.