{"record":{"id":"ca5449897b90f0ad","repo":"astrid-runtime/astrid","slug":"resolve-astridhome-e","errorCode":null,"errorMessage":"resolve AstridHome: {e}","messagePattern":"resolve AstridHome: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/astrid-daemon/src/lib.rs","lineNumber":481,"sourceCode":"///\n/// # Errors\n///\n/// Always returns an explicit unsupported-platform error.\n#[cfg(not(unix))]\n#[expect(\n    clippy::unused_async,\n    reason = \"the cross-platform daemon entry point remains async even when startup is unsupported\"\n)]\npub async fn run() -> Result<()> {\n    anyhow::bail!(\"native Astrid daemon startup is not yet supported on this platform\")\n}\n\n/// Load `etc/gateway-http.toml`. Returns `Ok(None)` when the file\n/// doesn't exist (single-tenant default).\n#[cfg(unix)]\nasync fn load_gateway_config() -> Result<Option<astrid_gateway::GatewayConfig>> {\n    let home = astrid_core::dirs::AstridHome::resolve()\n        .map_err(|e| anyhow::anyhow!(\"resolve AstridHome: {e}\"))?;\n    let path = home.etc_dir().join(\"gateway-http.toml\");\n    let text = match tokio::fs::read_to_string(&path).await {\n        Ok(b) => b,\n        Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(None),\n        Err(e) => return Err(anyhow::anyhow!(\"read {}: {e}\", path.display())),\n    };\n    let cfg: astrid_gateway::GatewayConfig =\n        toml::from_str(&text).context(\"parse gateway-http.toml\")?;\n    cfg.validate().context(\"validate gateway-http.toml\")?;\n    Ok(Some(cfg))\n}\n\n#[cfg(unix)]\nfn spawn_gateway(\n    cfg: astrid_gateway::GatewayConfig,\n    kernel: &std::sync::Arc<astrid_kernel::Kernel>,\n) -> Result<std::sync::Arc<tokio::sync::Notify>> {\n    // Plumb four kernel handles into the gateway:","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-daemon/src/lib.rs#L463-L499","documentation":"`load_gateway_config` resolves the AstridHome directory layout via `astrid_core::dirs::AstridHome::resolve()` to locate `etc/gateway-http.toml`. If home resolution itself fails (cannot determine or create the astrid home directories), this error wraps the cause. A missing gateway-http.toml is fine (returns Ok(None)); only a broken home resolution is fatal.","triggerScenarios":"Calling `load_gateway_config()` (from daemon `run()`, unix only) when `AstridHome::resolve()` errors — e.g. HOME is unset/invalid on unix, or the home directory tree cannot be created.","commonSituations":"Running the daemon under systemd/CI with HOME unset; XDG/home variables pointing at non-existent or unwritable paths.","solutions":["Check the wrapped `{e}` for which home path failed.","Ensure HOME (and relevant XDG vars) is set to an existing, writable directory for the daemon process.","Pre-create or fix permissions on the astrid home directory."],"exampleFix":"// systemd unit before\n[Service]\nExecStart=/usr/bin/astrid-daemon\n// after\n[Service]\nEnvironment=HOME=/var/lib/astrid\nExecStart=/usr/bin/astrid-daemon","handlingStrategy":"validation","validationCode":"// shell\n: \"${HOME:?HOME must be set for astrid daemon}\" && [ -d \"$HOME\" ] || { echo \"HOME not a directory\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"// rust\nmatch load_gateway_config().await {\n    Ok(cfg) => { /* Ok(None) means no gateway-http.toml — fine */ }\n    Err(e) => { eprintln!(\"gateway config: {e:#}\"); }\n}","preventionTips":["Set HOME explicitly in service units, containers, and CI jobs.","Point XDG/home vars at existing writable directories.","Remember a missing gateway-http.toml is valid; only a broken home resolution errors."],"tags":["filesystem","config","home-directory"],"backgroundTag":"directory-not-found","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}