ruvnet/RuView · error
cannot write {}: {e}
Error message
cannot write {}: {e} What it means
std::fs::write failed to persist the pretty-printed enrollment JSON to --output at the end of a completed enroll session. OS-level io::Error: missing parent directory, permissions, disk full, or the path naming a directory. The interactive anchor captures succeeded but the features exist only in memory, so a write failure means re-enrolling.
Source
Thrown at v2/crates/wifi-densepose-cli/src/room.rs:208
}
}
if session.is_complete() {
session.apply(EnrollmentEvent::Completed { at: now_unix() });
}
let (got, total) = session.progress();
let data = EnrollmentData {
room_id: args.room_id.clone(),
baseline_id,
fs_hz: args.fs_hz,
anchors: features,
session,
};
std::fs::write(
&args.output,
serde_json::to_string_pretty(&data).map_err(|e| anyhow::anyhow!("serialize: {e}"))?,
)
.map_err(|e| anyhow::anyhow!("cannot write {}: {e}", args.output))?;
eprintln!(
"\n[enroll] done: {got}/{total} anchors accepted → {} (next: `train-room`)",
args.output
);
Ok(())
}
// ---------------------------------------------------------------------------
// train-room
// ---------------------------------------------------------------------------
/// Arguments for `train-room`.
#[derive(Args, Debug, Clone)]
pub struct TrainRoomArgs {
/// Enrollment file from `enroll`.
#[arg(long, default_value = "./enrollment.json")]
pub enrollment: String,
/// Output specialist-bank file.View on GitHub (pinned to 4685618388)
Solutions
- Create the parent directory before starting enroll (mkdir -p)
- Fix permissions/ownership on the output directory
- Free disk space or choose another --output path
- Confirm the path is a file location, then re-run the enrollment
Example fix
// before
std::fs::write(
&args.output,
serde_json::to_string_pretty(&data).map_err(|e| anyhow::anyhow!("serialize: {e}"))?,
)
.map_err(|e| anyhow::anyhow!("cannot write {}: {e}", args.output))?;
// after
if let Some(parent) = std::path::Path::new(&args.output).parent() {
std::fs::create_dir_all(parent)
.map_err(|e| anyhow::anyhow!("cannot create {}: {e}", parent.display()))?;
}
std::fs::write(
&args.output,
serde_json::to_string_pretty(&data).map_err(|e| anyhow::anyhow!("serialize: {e}"))?,
)
.map_err(|e| anyhow::anyhow!("cannot write {}: {e}", args.output))?; Defensive patterns
Strategy: validation
Validate before calling
fn enrollment_output_ok(path: &str) -> bool {
let p = std::path::Path::new(path);
p.parent().map(|d| d.is_dir()).unwrap_or(true)
&& !p.is_dir()
&& std::fs::OpenOptions::new().write(true).create(true).truncate(false).open(p).is_ok()
} Prevention
- Validate --output writability BEFORE starting the interactive anchor prompts — a failure after capture wastes the whole session
- Script enroll runs with pre-created output directories
- Keep disk headroom on the volume holding enrollment artifacts
When it happens
Trigger: --output pointing into a nonexistent directory; unwritable or foreign-owned target; disk full; --output naming an existing directory.
Common situations: Fresh directories never created; running as a different user; full disks in constrained environments — especially costly here because the whole interactive session must be repeated.
Related errors
- cannot write {output}: {e}
- cannot read {}: {e} — run `enroll` first
- cannot read {path}: {e}
- data_dir not accessible {}: {e}
- parent not accessible {}: {e}
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/7f059039b3f6bcdc.
Report an issue: GitHub.