ruvnet/RuView · error
cannot write {output}: {e}
Error message
cannot write {output}: {e} What it means
std::fs::write failed while persisting the serialized BaselineCalibration (to_bytes output) to the --output path in finalise_and_save. The underlying io::Error is OS-level: missing parent directory, permission denied, disk full, or the path naming an existing directory. The calibration itself succeeded; only persistence failed, and finalize() consumed the recorder, so the frames are lost unless re-captured.
Source
Thrown at v2/crates/wifi-densepose-cli/src/calibrate.rs:218
frames, target, score.amplitude_z_median, score.amplitude_z_max, motion_str
);
}
// ---------------------------------------------------------------------------
// Finalise + persist
// ---------------------------------------------------------------------------
fn finalise_and_save(recorder: CalibrationRecorder, output: &str) -> Result<()> {
let frames = recorder.frames_recorded();
eprintln!("[calibrate] finalising baseline from {frames} frames…");
let baseline: BaselineCalibration = recorder
.finalize()
.map_err(|e| anyhow::anyhow!("calibration failed: {e}"))?;
let bytes = baseline.to_bytes();
std::fs::write(output, &bytes)
.map_err(|e| anyhow::anyhow!("cannot write {output}: {e}"))?;
eprintln!(
"[calibrate] baseline saved to {output} ({} bytes)",
bytes.len()
);
eprintln!(
"[calibrate] summary: frames={} tier={:?} subcarriers={}",
baseline.frame_count,
baseline.tier,
baseline.subcarriers.len(),
);
Ok(())
}
// ---------------------------------------------------------------------------
// Tier helper
// ---------------------------------------------------------------------------
View on GitHub (pinned to 4685618388)
Solutions
- Create the parent directory of --output (mkdir -p) and re-run the calibration — the recorder was consumed, so frames must be re-captured
- Check ownership and permissions on the target directory (ls -ld, chown/chmod as needed)
- Point --output to a filesystem with free space
- Ensure --output is a file path, not an existing directory
Example fix
// before
let bytes = baseline.to_bytes();
std::fs::write(output, &bytes)
.map_err(|e| anyhow::anyhow!("cannot write {output}: {e}"))?;
// after
if let Some(parent) = std::path::Path::new(output).parent() {
std::fs::create_dir_all(parent)
.map_err(|e| anyhow::anyhow!("cannot create {}: {e}", parent.display()))?;
}
let bytes = baseline.to_bytes();
std::fs::write(output, &bytes)
.map_err(|e| anyhow::anyhow!("cannot write {output}: {e}"))?; Defensive patterns
Strategy: validation
Validate before calling
fn output_writable(path: &str) -> bool {
let p = std::path::Path::new(path);
p.parent().map(|d| d.is_dir()).unwrap_or(true)
&& std::fs::OpenOptions::new().write(true).create(true).truncate(false).open(p).is_ok()
} Try / catch
match std::fs::write(output, &bytes) {
Ok(()) => {}
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
eprintln!("parent directory missing for {output} — mkdir -p it");
}
Err(e) => return Err(anyhow::anyhow!("cannot write {output}: {e}")),
} Prevention
- Validate the output path before starting a multi-minute capture so the recording is not wasted
- Run the CLI as a user that owns the output directory
- Keep free disk space for the baseline artifact
When it happens
Trigger: --output points into a directory that does not exist; the target directory is read-only or owned by another user; disk fills after a long capture; --output names an existing directory.
Common situations: Writing to an artifacts/ path never created in a fresh checkout; running the CLI as a different user than the directory owner; small tmpfs in containers; typos in the output path.
Related errors
- cannot create output dir {}: {e}
- cannot read baseline {path}: {e} — run `calibrate` first
- cannot write {}: {e}
- cannot read {path}: {e}
- data_dir not accessible {}: {e}
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/942d38d3668cc8bf.
Report an issue: GitHub.