{"record":{"id":"b58472d7b46265ae","repo":"run-llama/liteparse","slug":"failed-to-create-temp-dir","errorCode":null,"errorMessage":"failed to create temp dir","messagePattern":"failed to create temp dir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pdfium-sys/build.rs","lineNumber":185,"sourceCode":"    let tag_encoded = PDFIUM_RELEASE_TAG.replace('/', \"%2F\");\n    let url = format!(\"{PDFIUM_RELEASE_URL}/{tag_encoded}/{asset}\");\n\n    eprintln!(\"pdfium-sys: GET {url}\");\n\n    let response = ureq::get(&url).call().unwrap_or_else(|e| {\n        panic!(\"failed to download pdfium from {url}: {e}\");\n    });\n\n    let reader = response.into_body().into_reader();\n    let gz = flate2::read::GzDecoder::new(reader);\n    let mut archive = tar::Archive::new(gz);\n\n    // Extract to a temp dir first, then rename atomically\n    let tmp = dest.with_extension(\"tmp\");\n    if tmp.exists() {\n        fs::remove_dir_all(&tmp).ok();\n    }\n    fs::create_dir_all(&tmp).expect(\"failed to create temp dir\");\n    archive\n        .unpack(&tmp)\n        .expect(\"failed to extract pdfium archive\");\n\n    // Fix dylib install name on macOS so @rpath resolution works\n    fix_dylib_install_name(&tmp);\n\n    // Atomic rename into place\n    if dest.exists() {\n        fs::remove_dir_all(dest).ok();\n    }\n    fs::rename(&tmp, dest).expect(\"failed to move pdfium to cache dir\");\n\n    eprintln!(\"pdfium-sys: cached pdfium at {}\", dest.display());\n}\n\n/// On macOS, pdfium-binaries ships dylibs with install name `./libpdfium.dylib`.\n/// We need `@rpath/libpdfium.dylib` for rpath resolution to work.","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/crates/pdfium-sys/build.rs#L167-L203","documentation":"download_pdfium extracts the downloaded pdfium archive into a temporary sibling directory (<dest>.tmp) before atomically renaming it into the cache. fs::create_dir_all(&tmp).expect(...) panics with this message if the temp directory cannot be created — typically a filesystem or permissions failure at the cache location. The build script has no graceful failure path here, so the whole build aborts.","triggerScenarios":"Running `cargo build` where pdfium-sys must download pdfium and the parent cache directory is not writable or does not exist and cannot be created — e.g. HOME points to a read-only path, disk full, or the leftover .tmp path exists as a file instead of a directory.","commonSituations":"Read-only Docker build layers or read-only caches; sandboxes/SELinux blocking writes to the home cache dir; full disks on CI machines; a corrupted cache where pdfium.tmp exists as a regular file that remove_dir_all couldn't clean up.","solutions":["Ensure the cache parent directory (from dirs_cache: ~/.cache, ~/Library/Caches, or %LOCALAPPDATA%) exists and is writable by the build user.","Delete any stale <cache>/pdfium-<ver>.tmp path that may be a file or corrupted directory, then rebuild.","Check free disk space and clean the build/cache directories.","Point the cache to a writable location (set HOME to a writable dir, per the related HOME errors)."],"exampleFix":"# before: failing build with unwritable cache\n$ cargo build\n   ... panicked: failed to create temp dir\n\n# after: clear stale tmp and fix permissions\n$ rm -rf ~/.cache/liteparse/pdfium*.tmp\n$ chmod u+w ~/.cache && cargo build","handlingStrategy":"validation","validationCode":"# Preflight: ensure pdfium cache dir is writable\nCACHE=\"$HOME/.cache/liteparse\"\nmkdir -p \"$CACHE\" && [ -w \"$CACHE\" ] || { echo \"cache dir not writable: $CACHE\"; exit 1; }\nrm -rf \"$CACHE\"/pdfium*.tmp","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the cache directory is writable before building","Clean stale .tmp entries after interrupted builds","Monitor disk space on CI machines","Point HOME to a writable, non-read-only path in containers"],"tags":["build-script","filesystem","permissions","pdfium","download"],"backgroundTag":"file-write-failed","analyzedSha":"22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8","analyzedAt":"2026-09-08T06:09:49.009Z","contentChangedAt":"2026-09-08T06:09:49.009Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}