{"record":{"id":"aac90af503ddfbe3","repo":"unicity-aos/aos-ce","slug":"aos-home-and-home-are-both-unset","errorCode":null,"errorMessage":"AOS_HOME and HOME are both unset","messagePattern":"AOS_HOME and HOME are both unset","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/unicity-aos-bootstrap/src/lib.rs","lineNumber":623,"sourceCode":"        return Ok(home);\n    }\n\n    match (get(\"HOMEDRIVE\"), get(\"HOMEPATH\")) {\n        (Some(drive), Some(path)) => Ok(PathBuf::from(drive).join(path).into_os_string()),\n        _ => Err(io::Error::new(\n            io::ErrorKind::NotFound,\n            \"AOS_HOME, USERPROFILE, and HOMEDRIVE/HOMEPATH are all unset\",\n        )),\n    }\n}\n\n#[cfg(not(windows))]\nfn default_home<F>(get: &F) -> io::Result<OsString>\nwhere\n    F: Fn(&str) -> Option<OsString>,\n{\n    get(\"HOME\")\n        .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, \"AOS_HOME and HOME are both unset\"))\n}\n\n#[cfg(windows)]\nconst fn default_home_name() -> &'static str {\n    \"USERPROFILE\"\n}\n\n#[cfg(not(windows))]\nconst fn default_home_name() -> &'static str {\n    \"HOME\"\n}\n\nconst fn runtime_binary_name() -> &'static str {\n    RUNTIME_EXECUTABLE_NAMES[0]\n}\n\nconst fn runtime_daemon_binary_name() -> &'static str {\n    RUNTIME_EXECUTABLE_NAMES[1]","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/crates/unicity-aos-bootstrap/src/lib.rs#L605-L641","documentation":"The non-Windows branch of default_home (crates/unicity-aos-bootstrap/src/lib.rs:617) resolves the AOS home directory from AOS_HOME first, then falls back to HOME; if HOME is also unset it throws this io::Error (NotFound). The library cannot determine where to place its default state/runtime layout.","triggerScenarios":"Calling resolve_with or default_legacy_runtime_home on Linux/macOS when neither AOS_HOME nor HOME is set in the process environment — e.g. a daemon launched by systemd/cron with a minimal env, a container running as a user with no passwd entry, or a process spawned with env_clear().","commonSituations":"systemd units with 'Environment=' stripped; Docker images running as non-root users created without a home directory; CI jobs with sanitized environments; setuid or service wrappers that scrub HOME.","solutions":["Set AOS_HOME explicitly to the state directory and retry.","Ensure HOME is exported in the execution environment (e.g. HOME=/root or the user's home).","In systemd, add Environment=\"HOME=/var/lib/<user>\" to the unit or use EnvironmentFile.","If spawning the process yourself, inherit the parent environment rather than env_clear()."],"exampleFix":"// before\nCommand::new(\"aos\").env_clear().status()\n// after\nCommand::new(\"aos\").env(\"AOS_HOME\", \"/var/lib/aos\").status()","handlingStrategy":"fallback","validationCode":"let home = std::env::var_os(\"AOS_HOME\").or_else(|| std::env::var_os(\"HOME\"));\nif home.is_none() {\n    return Err(\"set AOS_HOME or HOME before running\".into());\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound && e.to_string().contains(\"AOS_HOME and HOME are both unset\") => {\n        eprintln!(\"no home directory in environment; set AOS_HOME=<dir> or HOME=<dir> and retry\");\n    }\n    other => other?,\n}","preventionTips":["Set AOS_HOME explicitly in systemd units, cron jobs, and container entrypoints.","Verify containers/users have a home directory in /etc/passwd, or export HOME in the entrypoint.","Avoid env_clear() when spawning; inherit or explicitly pass HOME."],"tags":["environment","unix","home-directory","rust"],"backgroundTag":"missing-env-var","analyzedSha":"f6f22024fb1e8d122f28a1b4a9f75aee448ae839","analyzedAt":"2026-09-13T03:04:44.565Z","contentChangedAt":"2026-09-13T03:04:44.565Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}