zed-industries/zed · error

Failed to open output file for rewriting

Error message

Failed to open output file for rewriting

What it means

Panics in the edit prediction CLI when reopening the JSONL output file with truncation for the resume pass fails (permissions, path moved, disk full). The tool rewrites the file with only unprocessed examples.

Source

Thrown at crates/edit_prediction_cli/src/main.rs:1067

                    kept_lines.push(line);
                }
            }
        }
    }

    let total = examples.len();
    let already_processed = kept_hashes.len();

    eprintln!(
        "Resuming: {}/{} examples already processed",
        already_processed, total
    );

    let file = OpenOptions::new()
        .write(true)
        .truncate(true)
        .open(path)
        .expect("Failed to open output file for rewriting");
    let mut writer = BufWriter::new(file);
    for line in &kept_lines {
        writeln!(writer, "{}", line).expect("Failed to write to output file");
    }
    writer.flush().expect("Failed to flush output file");

    examples.retain(|e| !kept_hashes.contains(&spec_hash(&e.spec)));
}

fn main() {
    let args = EpArgs::parse();

    if args.printenv {
        ::util::shell_env::print_env();
        return;
    }

    let output = args.output_path();

View on GitHub (pinned to f4178619ac)

Solutions

  1. Check the output path is writable and the disk has space
  2. Ensure no other process holds the output file open
  3. Re-run from a directory with write permissions
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/edit_prediction_cli/src/main.rs:1067 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/25ad49d795450a5b. Report an issue: GitHub.