{"record":{"id":"c7ad83d64f67936a","repo":"run-llama/liteparse","slug":"failed-to-extract-pdfium-archive","errorCode":null,"errorMessage":"failed to extract pdfium archive","messagePattern":"failed to extract pdfium archive","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pdfium-sys/build.rs","lineNumber":188,"sourceCode":"    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.\nfn fix_dylib_install_name(dir: &Path) {\n    let target_os = env::var(\"CARGO_CFG_TARGET_OS\").unwrap_or_default();\n    if target_os != \"macos\" {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/crates/pdfium-sys/build.rs#L170-L206","documentation":"After creating the temp dir, download_pdfium unpacks the downloaded tar/zip archive into it with the `tar` crate's unpack, panicking with this message on failure. Failures here mean the archive is corrupt, truncated, or in an unsupported format (e.g. a failed download that saved an HTML error page, or a platform archive variant the extractor can't read).","triggerScenarios":"Running `cargo build` where pdfium-sys downloads a pdfium release archive and unpack fails: network proxy/captive portal returned an HTML error page saved as the archive, the download was truncated, the tar contains unsupported entry types (symlinks/hardlinks on Windows), or the archive format doesn't match the expected one.","commonSituations":"Corporate proxies intercepting the download URL; flaky networks mid-download; GitHub releases changing their archive layout; restrictive sandboxes that strip symlink entries from the tarball.","solutions":["Delete the cached/partial download in the pdfium cache dir and rebuild to force a fresh download.","Check network/proxy: ensure the pdfium release URL is reachable and not intercepted (curl the URL and inspect the response).","Verify the archive manually (tar -tf / unzip -l) to confirm integrity and format.","Retry the build after a transient network failure; if behind a proxy, configure HTTPS_PROXY properly."],"exampleFix":"# before: corrupt cached archive\n$ cargo build\n   ... panicked: failed to extract pdfium archive\n\n# after: purge cache and retry\n$ rm -rf ~/.cache/liteparse/pdfium*\n$ unset HTTP_PROXY HTTPS_PROXY  # or fix proxy config\n$ cargo build","handlingStrategy":"retry","validationCode":"# Verify the archive downloads intact before building\ncurl -fSL -o /tmp/pdfium.tar.gz \"$PDFIUM_URL\" && tar -tzf /tmp/pdfium.tar.gz > /dev/null || { echo \"bad download\"; exit 1; }","typeGuard":null,"tryCatchPattern":"# Build wrapper: retry once after clearing a failed extraction\nfor i in 1 2; do\n  cargo build && break\n  rm -rf ~/.cache/liteparse/pdfium*\ndone","preventionTips":["Clear the pdfium cache after any network hiccup","Bypass/fix intercepting proxies for release-download URLs","Verify archive integrity with tar -t / unzip -l when debugging","Retry transient download failures with fresh cache"],"tags":["build-script","archive","download","corrupt-file","pdfium"],"backgroundTag":"archive-extraction-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"}