{"record":{"id":"01c6433a0932c3ec","repo":"astrid-runtime/astrid","slug":"neither-astrid-home-nor-home-environment-variable","errorCode":null,"errorMessage":"neither ASTRID_HOME nor HOME environment variable is set","messagePattern":"neither ASTRID_HOME nor HOME environment variable is set","errorType":"exception","errorClass":"std::io::Error::NotFound","httpStatus":null,"severity":"error","filePath":"crates/astrid-core/src/dirs.rs","lineNumber":299,"sourceCode":"            Self::resolve_with_env(None, std::env::var(\"HOME\").ok())\n        }\n    }\n\n    /// Internal resolver used to mock environment variables in tests securely.\n    fn resolve_with_env(astrid_home: Option<String>, home: Option<String>) -> io::Result<Self> {\n        let root = if let Some(custom) = astrid_home {\n            let p = PathBuf::from(&custom);\n            if !p.is_absolute() {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"ASTRID_HOME must be an absolute path\",\n                ));\n            }\n            reject_parent_traversal(&p, \"ASTRID_HOME\")?;\n            p\n        } else {\n            let home = home.ok_or_else(|| {\n                io::Error::new(\n                    io::ErrorKind::NotFound,\n                    \"neither ASTRID_HOME nor HOME environment variable is set\",\n                )\n            })?;\n            let home_path = PathBuf::from(&home);\n            if !home_path.is_absolute() {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"HOME must be an absolute path\",\n                ));\n            }\n            reject_parent_traversal(&home_path, \"HOME\")?;\n            home_path.join(\".astrid\")\n        };\n\n        Ok(Self { root })\n    }\n","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-core/src/dirs.rs#L281-L317","documentation":"Thrown by resolve_with_env when neither ASTRID_HOME nor HOME is present in the environment, so no home directory root can be determined. It is a NotFound error because a required environment input is missing.","triggerScenarios":"Calling the directory resolver in an environment where both ASTRID_HOME and HOME are unset, e.g. stripped env in systemd services, cron, containers, or tests with cleared env.","commonSituations":"Running an Astrid CLI command under a service manager that purges the environment, Docker containers without HOME set, or CI jobs running with env -i.","solutions":["Set ASTRID_HOME to an absolute path in the execution environment","Ensure HOME is exported for the user running the process","Fix the service/container definition so the env var is passed through"],"exampleFix":"// before: systemd unit without environment\n[Service]\nExecStart=/usr/bin/astrid\n// after\n[Service]\nEnvironment=\"HOME=/home/astrid\"\nExecStart=/usr/bin/astrid","handlingStrategy":"validation","validationCode":"if std::env::var(\"ASTRID_HOME\").is_err() && std::env::var(\"HOME\").is_err() {\n    std::env::set_var(\"ASTRID_HOME\", \"/var/lib/astrid\");\n}","typeGuard":"fn has_home_env() -> bool {\n    std::env::var(\"ASTRID_HOME\").is_ok() || std::env::var(\"HOME\").is_ok()\n}","tryCatchPattern":"match dirs_result {\n    Err(e) if e.kind() == io::ErrorKind::NotFound => {\n        eprintln!(\"Set ASTRID_HOME or HOME before running\");\n    },\n    other => other?,\n}","preventionTips":["Set Environment=HOME=... in systemd units","Ensure containers define HOME for the runtime user","Check `env | grep HOME` in CI/service environments"],"tags":["env-var","config","deployment"],"backgroundTag":"missing-env-var","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"}