{"record":{"id":"e32c22cba1448782","repo":"can1357/oh-my-pi","slug":"failed-to-write-e","errorCode":null,"errorMessage":"failed to write {}: {e}","messagePattern":"failed to write (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/pi-natives/build.rs","lineNumber":63,"sourceCode":"\t\t\t\t\t.and_then(|n| n.to_str())\n\t\t\t\t\t.unwrap_or(\"unknown\");\n\t\t\t\twriteln!(concatenated, \"# --- {filename} ---\").expect(\"write to String\");\n\t\t\t\tfor line in body.lines() {\n\t\t\t\t\tlet trimmed = line.trim_start();\n\t\t\t\t\tif trimmed.starts_with(\"schema_version\") {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconcatenated.push_str(line);\n\t\t\t\t\tconcatenated.push('\\n');\n\t\t\t\t}\n\t\t\t\tconcatenated.push('\\n');\n\t\t\t},\n\t\t\tErr(e) => panic!(\"failed to read filter definition {}: {e}\", path.display()),\n\t\t}\n\t}\n\n\tfs::write(&output_path, concatenated)\n\t\t.unwrap_or_else(|e| panic!(\"failed to write {}: {e}\", output_path.display()));\n}\n","sourceCodeStart":45,"sourceCodeEnd":65,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-natives/build.rs#L45-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check free disk space (`df -h` on the target filesystem) and clear space or point CARGO_TARGET_DIR at a volume with room.","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`).","If target/ is on a read-only mount, remount read-write or move CARGO_TARGET_DIR to a writable location.","Run `cargo clean -p pi-natives` to drop any corrupted OUT_DIR and let the build script regenerate it."],"exampleFix":"// before: OUT_DIR unwritable (root-owned target/)\n// panic: failed to write /build/target/.../out/builtin_filters.toml: Permission denied (os error 13)\n\n// after: take ownership of target and rebuild\n$ sudo chown -R $(whoami) target\n$ cargo build -p pi-natives","handlingStrategy":"validation","validationCode":"# Run before building to ensure OUT_DIR's filesystem is writable and has space:\ndf -h . | awk 'NR==2 { if ($4+0 < 1) { print \"less than 1G free\"; exit 1 } }'\ntouch \"${CARGO_TARGET_DIR:-target}/.write-test\" && rm \"${CARGO_TARGET_DIR:-target}/.write-test\"","typeGuard":null,"tryCatchPattern":"if ! cargo build -p pi-natives 2>build.log; then\n  grep -q 'failed to write' build.log && \\\n    echo \"OUT_DIR unwritable: check disk space and target/ permissions\"\n  exit 1\nfi","preventionTips":["Keep several GB free on the filesystem holding target/ (or set CARGO_TARGET_DIR elsewhere).","Never build with a root-owned or read-only target/ directory; chown after CI cache restores.","Run cargo clean -p pi-natives when switching containers/users to regenerate a fresh OUT_DIR."],"tags":["build-script","filesystem","disk","compile-time"],"backgroundTag":"build-script-io-failure","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}