{"record":{"id":"475d6e5fec24bcb2","repo":"run-llama/liteparse","slug":"unable-to-generate-bindings","errorCode":null,"errorMessage":"Unable to generate bindings","messagePattern":"Unable to generate bindings","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/pdfium-sys/build.rs","lineNumber":286,"sourceCode":"        let bindings = bindgen::Builder::default()\n            .header(\"wrapper.h\")\n            .clang_arg(format!(\"-I{}\", include_dir.display()))\n            .allowlist_function(\"FPDF.*\")\n            .allowlist_function(\"FORM_.*\")\n            .allowlist_function(\"FPDFText_.*\")\n            .allowlist_function(\"FPDFPage.*\")\n            .allowlist_function(\"FPDFLink_.*\")\n            .allowlist_function(\"FPDFFont_.*\")\n            .allowlist_type(\"FPDF.*\")\n            .allowlist_type(\"FS_.*\")\n            .allowlist_var(\"FPDF.*\")\n            .allowlist_var(\"FLAT.*\")\n            .derive_debug(true)\n            .derive_default(true)\n            .layout_tests(false)\n            .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))\n            .generate()\n            .expect(\"Unable to generate bindings\");\n\n        bindings\n            .write_to_file(&out_file)\n            .expect(\"Couldn't write bindings!\");\n    }\n\n    #[cfg(not(feature = \"bindgen\"))]\n    {\n        let _ = include_dir;\n        let pregenerated = Path::new(env!(\"CARGO_MANIFEST_DIR\")).join(\"bindings.rs\");\n        fs::copy(&pregenerated, &out_file).unwrap_or_else(|e| {\n            panic!(\n                \"Failed to copy pre-generated bindings from {}: {e}\",\n                pregenerated.display()\n            )\n        });\n    }\n}","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/crates/pdfium-sys/build.rs#L268-L304","documentation":"The pdfium-sys build script panics because bindgen failed to generate Rust FFI bindings from the PDFium C headers (the `bindgen::Builder::generate()` call returned an Err). This happens when libclang cannot parse `wrapper.h` or the PDFium headers found under the include directory. It is a build-time panic, so the crate fails to compile with this message as the panic output.","triggerScenarios":"Building pdfium-sys with the `bindgen` feature enabled and either (a) the PDFium C headers are missing/incomplete in the include dir passed via `-I`, (b) libclang is absent or an incompatible version, or (c) the header contents are malformed/incompatible so the clang parse fails and `generate()` returns Err.","commonSituations":"Fresh CI/dev machines without libclang installed (e.g. no `libclang-dev` / LLVM installed); a PDFium checkout where the `public/` include dir is wrong or empty; PDFium version changes introducing headers bindgen cannot parse; cross-compiling where the wrong libclang/headers are picked up.","solutions":["Install libclang (e.g. `apt install libclang-dev` / `brew install llvm` and set LIBCLANG_PATH) and rebuild.","Verify the include directory contains the PDFium public headers (fpdfview.h etc.) and is correctly passed to the build script; fix the path/env var that supplies it.","Build with the `bindgen` feature disabled so the pre-generated `bindings.rs` shipped in the crate is used instead of running bindgen.","Pin/check the PDFium version whose headers are being parsed; regenerate or update bindgen if the headers use unsupported constructs."],"exampleFix":"// before: failing build with missing libclang\n# apt install clang libclang-dev\n# export LIBCLANG_PATH=/usr/lib/llvm-14/lib\n\n// or, in Cargo.toml, skip bindgen entirely and use the pre-generated bindings\n// before\ncargo build -p pdfium-sys --features bindgen\n// after\ncargo build -p pdfium-sys","handlingStrategy":"validation","validationCode":"# shell — before building\ncargo build -p pdfium-sys --features bindgen 2>&1 | grep -q 'Unable to generate bindings' && \\\n  echo 'check libclang + PDFium headers'\n# or programmatically ensure prerequisites:\nwhich clang; echo $LIBCLANG_PATH; ls $PDFIUM_INCLUDE/fpdfview.h","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install libclang as a pinned CI dependency (e.g. apt install libclang-dev) before cargo build","Prefer the default (non-bindgen) build that uses the pre-generated bindings.rs","Assert the PDFium include dir exists and contains fpdfview.h in build scripts/CI setup","Pin bindgen and PDFium header versions known to work together"],"tags":["build","bindgen","ffi","libclang","rust"],"backgroundTag":"module-init-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"}