earendil-works/pi · error
Could not edit file: ${path}. ${errorMessage}.
Error message
Could not edit file: ${path}. ${errorMessage}. What it means
Error "Could not edit file: ${path}. ${errorMessage}." thrown in earendil-works/pi.
Source
Thrown at packages/coding-agent/src/core/tools/edit.ts:354
return withFileMutationQueue(absolutePath, async () => {
// Do not reject from an abort event listener here: that would release the
// mutation queue while an in-flight filesystem operation may still finish.
// Checking signal.aborted after each await observes the same aborts while
// keeping the queue locked until the current operation has settled.
const throwIfAborted = (): void => {
if (signal?.aborted) throw new Error("Operation aborted");
};
throwIfAborted();
// Check if file exists.
try {
await ops.access(absolutePath);
} catch (error: unknown) {
throwIfAborted();
const errorMessage =
error instanceof Error && "code" in error ? `Error code: ${error.code}` : String(error);
throw new Error(`Could not edit file: ${path}. ${errorMessage}.`);
}
throwIfAborted();
// Read the file.
const buffer = await ops.readFile(absolutePath);
const rawContent = buffer.toString("utf-8");
throwIfAborted();
// Strip BOM before matching. The model will not include an invisible BOM in oldText.
const { bom, text: content } = splitBom(rawContent);
const originalEnding = detectLineEnding(content);
const normalizedContent = normalizeToLF(content);
const { baseContent, newContent } = applyEditsToNormalizedContent(normalizedContent, edits, path);
throwIfAborted();
const finalContent = bom + restoreLineEndings(newContent, originalEnding);
await ops.writeFile(absolutePath, finalContent);
throwIfAborted();View on GitHub (pinned to 4af9d21d3b)
When it happens
Trigger: Thrown at packages/coding-agent/src/core/tools/edit.ts:354 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/6ea74ea7fcc66cf4.
Report an issue: GitHub.