run-llama/liteparse · error
HOME env var not set
Error message
HOME env var not set
What it means
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.
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.
Example fix
// before: Dockerfile build step without HOME USER app RUN cargo build --release // after USER app ENV HOME=/home/app RUN cargo build --release
Defensive patterns
Strategy: validation
Validate before calling
# Shell preflight before cargo build
[ -n "$HOME" ] || { echo "HOME is not set"; exit 1; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- USERPROFILE env var not set
- failed to create temp dir
- failed to extract pdfium archive
- failed to move pdfium to cache dir
- WASI proc_exit called with code
AI-assisted analysis of run-llama/liteparse@22d2dd8cd7 (2026-09-08).
Data as JSON: /api/errors/7a0e30300aebdb51.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pdfium-sys/build.rs:138
}
fn dirs_cache() -> PathBuf {
if let Ok(xdg) = env::var("XDG_CACHE_HOME") {
return PathBuf::from(xdg);
}
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
// Windows -> USERPROFILE
if target_os == "windows" {
if let Ok(local_app_data) = env::var("LOCALAPPDATA") {
return PathBuf::from(local_app_data);
}
let home = env::var("USERPROFILE").expect("USERPROFILE env var not set");
return PathBuf::from(home).join("AppData\\Local");
}
let home = env::var("HOME").expect("HOME env var not set");
if target_os == "macos" {
PathBuf::from(&home).join("Library/Caches")
} else {
PathBuf::from(&home).join(".cache")
}
}
/// Map target triple to the pdfium-binaries asset name (without .tgz).
fn pdfium_asset_stem() -> &'static str {
let target = env::var("TARGET").unwrap();
match target.as_str() {
"aarch64-apple-darwin" => "pdfium-mac-arm64",
"x86_64-apple-darwin" => "pdfium-mac-x64",
// Universal macOS binary works for both, but we prefer arch-specific
"x86_64-unknown-linux-gnu" => "pdfium-linux-x64",
"x86_64-unknown-linux-musl" => "pdfium-linux-musl-x64",
"aarch64-unknown-linux-gnu" | "aarch64-unknown-linux-musl" => "pdfium-linux-arm64",
"armv7-unknown-linux-gnueabihf" => "pdfium-linux-arm",View on GitHub (pinned to 22d2dd8cd7)