{"record":{"id":"7a0e30300aebdb51","repo":"run-llama/liteparse","slug":"home-env-var-not-set","errorCode":null,"errorMessage":"HOME env var not set","messagePattern":"HOME env var not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pdfium-sys/build.rs","lineNumber":138,"sourceCode":"}\n\nfn dirs_cache() -> PathBuf {\n    if let Ok(xdg) = env::var(\"XDG_CACHE_HOME\") {\n        return PathBuf::from(xdg);\n    }\n\n    let target_os = env::var(\"CARGO_CFG_TARGET_OS\").unwrap_or_default();\n\n    // Windows -> USERPROFILE\n    if target_os == \"windows\" {\n        if let Ok(local_app_data) = env::var(\"LOCALAPPDATA\") {\n            return PathBuf::from(local_app_data);\n        }\n        let home = env::var(\"USERPROFILE\").expect(\"USERPROFILE env var not set\");\n        return PathBuf::from(home).join(\"AppData\\\\Local\");\n    }\n\n    let home = env::var(\"HOME\").expect(\"HOME env var not set\");\n    if target_os == \"macos\" {\n        PathBuf::from(&home).join(\"Library/Caches\")\n    } else {\n        PathBuf::from(&home).join(\".cache\")\n    }\n}\n\n/// Map target triple to the pdfium-binaries asset name (without .tgz).\nfn pdfium_asset_stem() -> &'static str {\n    let target = env::var(\"TARGET\").unwrap();\n    match target.as_str() {\n        \"aarch64-apple-darwin\" => \"pdfium-mac-arm64\",\n        \"x86_64-apple-darwin\" => \"pdfium-mac-x64\",\n        // Universal macOS binary works for both, but we prefer arch-specific\n        \"x86_64-unknown-linux-gnu\" => \"pdfium-linux-x64\",\n        \"x86_64-unknown-linux-musl\" => \"pdfium-linux-musl-x64\",\n        \"aarch64-unknown-linux-gnu\" | \"aarch64-unknown-linux-musl\" => \"pdfium-linux-arm64\",\n        \"armv7-unknown-linux-gnueabihf\" => \"pdfium-linux-arm\",","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/crates/pdfium-sys/build.rs#L120-L156","documentation":"dirs_cache in pdfium-sys's build script resolves the user's cache root: on non-Windows platforms it reads HOME and panics with this message when the variable is unset. It then appends Library/Caches (macOS) or .cache (other Unix) to build the pdfium download cache path.","triggerScenarios":"Running `cargo build` on Linux/macOS with HOME unset or empty — e.g. cargo invoked from a systemd unit, a Docker container running as a non-root user without -e HOME, an SSH command with a sanitized environment, or a build service that strips env vars.","commonSituations":"Docker builds with `USER nonroot` but no HOME set; cron/systemd jobs lacking a login environment; CI containers where the build tool sanitizes the environment; Nix or chroot setups without a profile.","solutions":["Export HOME before building (e.g. HOME=/home/builduser cargo build).","In Docker, set ENV HOME=/home/user for the build stage or pass -e HOME in the run command.","Set the pdfium cache directory explicitly if the crate supports an override env var, bypassing dirs_cache.","Pre-seed the pdfium cache so no download/cache resolution is needed."],"exampleFix":"// before: Dockerfile build step without HOME\nUSER app\nRUN cargo build --release\n\n// after\nUSER app\nENV HOME=/home/app\nRUN cargo build --release","handlingStrategy":"validation","validationCode":"# Shell preflight before cargo build\n[ -n \"$HOME\" ] || { echo \"HOME is not set\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set ENV HOME in Dockerfiles for non-root build users","Use `env -i HOME=$HOME PATH=$PATH cargo build` style wrappers carefully — always keep HOME","For systemd/cron jobs, set Environment=HOME=/home/user in the unit"],"tags":["build-script","environment","pdfium","docker"],"backgroundTag":"missing-env-var","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"}