{"record":{"id":"93081f91597a0a03","repo":"BoundaryML/baml","slug":"could-not-determine-home-directory","errorCode":null,"errorMessage":"Could not determine home directory","messagePattern":"Could not determine home directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/playground-server/src/server.rs","lineNumber":192,"sourceCode":"        .ok_or_else(|| {\n            anyhow::anyhow!(\n                \"No checksum asset named '{}' in release\",\n                checksum_asset_name\n            )\n        })?;\n    let checksum_url = checksum_asset[\"browser_download_url\"]\n        .as_str()\n        .ok_or_else(|| anyhow::anyhow!(\"No download URL for checksum asset\"))?;\n\n    tracing::info!(\n        \"Found assets - main: {}, checksum: {}\",\n        download_url,\n        checksum_url\n    );\n\n    // Compute extraction directory using the provided version\n    let home =\n        dirs::home_dir().ok_or_else(|| anyhow::anyhow!(\"Could not determine home directory\"))?;\n    let extract_root: PathBuf = home\n        .join(\".baml/playground\")\n        .join(format!(\"web-panel-dist-{version}\"));\n    let dist_dir = extract_root.join(\"dist\");\n\n    // If already extracted, return the correct directory\n    if dist_dir.exists() && dist_dir.read_dir()?.next().is_some() {\n        tracing::info!(\"Web panel already extracted at: {}\", dist_dir.display());\n        return Ok(dist_dir.to_string_lossy().to_string());\n    } else if extract_root.exists() {\n        std::fs::remove_dir_all(&extract_root).with_context(|| {\n            format!(\n                \"Failed to remove old extraction directory: {}\",\n                extract_root.display()\n            )\n        })?;\n    }\n    std::fs::create_dir_all(&extract_root).with_context(|| {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/playground-server/src/server.rs#L174-L210","documentation":"get_playground_dist needs a directory under the user's home (~/.baml/playground) to cache the extracted web-panel dist. It calls dirs::home_dir() and errors when the OS yields no home directory. Without it, the server cannot locate or extract the playground static assets.","triggerScenarios":"Any request routed through playground_static_assets -> get_playground_dist when dirs::home_dir() returns None (e.g. no HOME env var on Unix, or unresolvable profile on Windows).","commonSituations":"Running the playground server in a container/systemd service with no HOME set; running as a system user with an unset home in /etc/passwd; stripped-down CI images where HOME is not exported.","solutions":["Set the HOME environment variable (Unix) or USERPROFILE (Windows) for the process running the playground server.","If running under systemd/Docker, add Environment=HOME=/root or run as a user with a valid passwd home entry.","Verify with: run the same command after `echo $HOME` prints a valid directory."],"exampleFix":"// before (Dockerfile)\nCMD [\"./baml-playground-server\"]\n// after\nENV HOME=/root\nCMD [\"./baml-playground-server\"]","handlingStrategy":"validation","validationCode":"// shell check before starting the server\n[ -n \"$HOME\" ] && [ -d \"$HOME\" ] || { echo 'HOME is not set'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always export HOME in container images and systemd units.","Run services as a named user with a valid passwd home entry.","Document required env vars for headless deployments."],"tags":["rust","filesystem","environment","home-directory"],"backgroundTag":"missing-env-var","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}