AprilNEA/OpenLogi · error
output already exists; pass --force to replace it after…
Error message
output {} already exists; pass --force to replace it after validation What it means
`ensure_output_available` refuses to overwrite an existing output file unless `--force` is passed. Output JSON files are written atomically (via AtomicWriteFile), but even atomically an existing file is never silently replaced — validation must complete and the operator must explicitly opt in with `--force`.
Solutions
- Re-run the command with `--force` after you have validated the replacement is intended.
- Delete or move the existing file first (`rm <path>` or `mv <path> <path>.bak`) and re-run without --force.
- Write to a fresh output directory so the id/output naming requirement yields an unused path.
Example fix
// before openlogi fixture contribute finish --id mx-master --name "MX Master" ... # output exists // after openlogi fixture contribute finish --id mx-master --name "MX Master" ... --force
Defensive patterns
Strategy: validation
Validate before calling
if [ -e "$OUT" ]; then echo "output exists; pass --force or remove it first" >&2; exit 1; fi
Try / catch
match write_outputs() {
Err(e) if e.to_string().contains("already exists; pass --force") => {
// prompt the user, then retry with force=true after validation
}
other => other?,
} Prevention
- Clean previous output artifacts before re-running generation.
- Only pass --force after reviewing the file that would be replaced.
- Use fresh output directories per contribution to avoid collisions.
When it happens
Trigger: Any command that writes an output JSON (via write_json_atomically) targets a path that already exists while `force` is false. Also triggered in the test `refuses_existing_files_without_force`.
Common situations: Re-running a contribute/generate step whose output file from a previous run still exists; a partially completed earlier attempt left artifacts behind.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- output must not be a symlink
- already exists but is not an in-progress OpenLogi…
- in-progress contribution contains unexpected entry
- in-progress contribution contains a non-UTF-8 entry
- resumable fixture cases contain a non-UTF-8 entry
AI-assisted analysis of AprilNEA/OpenLogi@e846e6f4b4 (2026-09-13).
Data as JSON: /api/errors/84e86bced6c1d87a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/openlogi-cli/src/cmd/fixture/output.rs:12
//! Validated fixture-only atomic publication.
use std::io::Write as _;
use std::path::Path;
use anyhow::{Context, Result, bail};
use atomic_write_file::AtomicWriteFile;
use serde::Serialize;
pub(super) fn ensure_output_available(path: &Path, force: bool) -> Result<()> {
if !force && path.try_exists().context("could not inspect output path")? {
bail!(
"output {} already exists; pass --force to replace it after validation",
path.display()
);
}
Ok(())
}
pub(super) fn write_json_atomically<T: Serialize>(
path: &Path,
value: &T,
force: bool,
asset: &str,
) -> Result<()> {
ensure_output_available(path, force)?;
let mut json =
serde_json::to_vec_pretty(value).with_context(|| format!("could not serialize {asset}"))?;
json.push(b'\n');
if let Some(parent) = pathView on GitHub (pinned to e846e6f4b4)