{"record":{"id":"942d38d3668cc8bf","repo":"ruvnet/RuView","slug":"cannot-write-output-e","errorCode":null,"errorMessage":"cannot write {output}: {e}","messagePattern":"cannot write (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/crates/wifi-densepose-cli/src/calibrate.rs","lineNumber":218,"sourceCode":"        frames, target, score.amplitude_z_median, score.amplitude_z_max, motion_str\n    );\n}\n\n// ---------------------------------------------------------------------------\n// Finalise + persist\n// ---------------------------------------------------------------------------\n\nfn finalise_and_save(recorder: CalibrationRecorder, output: &str) -> Result<()> {\n    let frames = recorder.frames_recorded();\n    eprintln!(\"[calibrate] finalising baseline from {frames} frames…\");\n\n    let baseline: BaselineCalibration = recorder\n        .finalize()\n        .map_err(|e| anyhow::anyhow!(\"calibration failed: {e}\"))?;\n\n    let bytes = baseline.to_bytes();\n    std::fs::write(output, &bytes)\n        .map_err(|e| anyhow::anyhow!(\"cannot write {output}: {e}\"))?;\n\n    eprintln!(\n        \"[calibrate] baseline saved to {output} ({} bytes)\",\n        bytes.len()\n    );\n    eprintln!(\n        \"[calibrate] summary: frames={} tier={:?} subcarriers={}\",\n        baseline.frame_count,\n        baseline.tier,\n        baseline.subcarriers.len(),\n    );\n    Ok(())\n}\n\n// ---------------------------------------------------------------------------\n// Tier helper\n// ---------------------------------------------------------------------------\n","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/v2/crates/wifi-densepose-cli/src/calibrate.rs#L200-L236","documentation":"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.","triggerScenarios":"--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.","commonSituations":"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.","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"],"exampleFix":"// before\nlet bytes = baseline.to_bytes();\nstd::fs::write(output, &bytes)\n    .map_err(|e| anyhow::anyhow!(\"cannot write {output}: {e}\"))?;\n\n// after\nif let Some(parent) = std::path::Path::new(output).parent() {\n    std::fs::create_dir_all(parent)\n        .map_err(|e| anyhow::anyhow!(\"cannot create {}: {e}\", parent.display()))?;\n}\nlet bytes = baseline.to_bytes();\nstd::fs::write(output, &bytes)\n    .map_err(|e| anyhow::anyhow!(\"cannot write {output}: {e}\"))?;","handlingStrategy":"validation","validationCode":"fn output_writable(path: &str) -> bool {\n    let p = std::path::Path::new(path);\n    p.parent().map(|d| d.is_dir()).unwrap_or(true)\n        && std::fs::OpenOptions::new().write(true).create(true).truncate(false).open(p).is_ok()\n}","typeGuard":null,"tryCatchPattern":"match std::fs::write(output, &bytes) {\n    Ok(()) => {}\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound => {\n        eprintln!(\"parent directory missing for {output} — mkdir -p it\");\n    }\n    Err(e) => return Err(anyhow::anyhow!(\"cannot write {output}: {e}\")),\n}","preventionTips":["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"],"tags":["rust","filesystem","io","calibration"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}