can1357/oh-my-pi · critical

failed to write {}: {e}

Error message

failed to write {}: {e}

What it means

After successfully concatenating all filter definitions, pi-natives' build script writes the generated builtin_filters.toml into the Cargo OUT_DIR. If fs::write fails (unwritable OUT_DIR, full disk, etc.) the build script panics with this message, aborting the cargo build. Unlike error 132 this happens after all inputs were read fine, so the problem is on the output side.

Source

Thrown at crates/pi-natives/build.rs:63

					.and_then(|n| n.to_str())
					.unwrap_or("unknown");
				writeln!(concatenated, "# --- {filename} ---").expect("write to String");
				for line in body.lines() {
					let trimmed = line.trim_start();
					if trimmed.starts_with("schema_version") {
						continue;
					}
					concatenated.push_str(line);
					concatenated.push('\n');
				}
				concatenated.push('\n');
			},
			Err(e) => panic!("failed to read filter definition {}: {e}", path.display()),
		}
	}

	fs::write(&output_path, concatenated)
		.unwrap_or_else(|e| panic!("failed to write {}: {e}", output_path.display()));
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Check free disk space (`df -h` on the target filesystem) and clear space or point CARGO_TARGET_DIR at a volume with room.
  2. Fix permissions on the target directory: `sudo chown -R $(whoami) target/` or rebuild after removing a root-owned target dir (`sudo rm -rf target && cargo build`).
  3. If target/ is on a read-only mount, remount read-write or move CARGO_TARGET_DIR to a writable location.
  4. Run `cargo clean -p pi-natives` to drop any corrupted OUT_DIR and let the build script regenerate it.

Example fix

// before: OUT_DIR unwritable (root-owned target/)
// panic: failed to write /build/target/.../out/builtin_filters.toml: Permission denied (os error 13)

// after: take ownership of target and rebuild
$ sudo chown -R $(whoami) target
$ cargo build -p pi-natives
Defensive patterns

Strategy: validation

Validate before calling

# Run before building to ensure OUT_DIR's filesystem is writable and has space:
df -h . | awk 'NR==2 { if ($4+0 < 1) { print "less than 1G free"; exit 1 } }'
touch "${CARGO_TARGET_DIR:-target}/.write-test" && rm "${CARGO_TARGET_DIR:-target}/.write-test"

Try / catch

if ! cargo build -p pi-natives 2>build.log; then
  grep -q 'failed to write' build.log && \
    echo "OUT_DIR unwritable: check disk space and target/ permissions"
  exit 1
fi

Prevention

When it happens

Trigger: Running `cargo build`/`cargo test` for pi-natives when the OUT_DIR target/.../build/pi-natives-*/out directory cannot be written to: disk full, read-only filesystem, quota exceeded, or OUT_DIR permissions broken.

Common situations: Disk quota or a full /tmp (Cargo puts OUT_DIR under target/ or a shared temp); building inside a container where target/ is mounted read-only; CI cache restoration leaving target/ owned by another user; filesystem errors on network mounts.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/e32c22cba1448782. Report an issue: GitHub.