{"record":{"id":"5fa46d0a06a2d75c","repo":"astrid-runtime/astrid","slug":"astrid-home-must-be-an-absolute-path","errorCode":null,"errorMessage":"ASTRID_HOME must be an absolute path","messagePattern":"ASTRID_HOME must be an absolute path","errorType":"validation","errorClass":"std::io::Error::InvalidInput","httpStatus":null,"severity":"error","filePath":"crates/astrid-core/src/dirs.rs","lineNumber":290,"sourceCode":"        #[cfg(windows)]\n        {\n            Ok(Self {\n                root: crate::platform_fs::default_astrid_home_root()?,\n            })\n        }\n\n        #[cfg(not(windows))]\n        {\n            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\",","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-core/src/dirs.rs#L272-L308","documentation":"Environment validation in AstridDirs::resolve_with_env: the ASTRID_HOME environment variable is set to a relative path (e.g. astrid-home instead of /abs/astrid-home). A relative home root would resolve against an unpredictable working directory and corrupt data placement, so the resolver returns an InvalidInput io error before any directory is created.","triggerScenarios":"Setting ASTRID_HOME to a relative path like '.astrid' or 'astrid-home' and calling the directory resolver (e.g. AstridDirs::resolve/prepare).","commonSituations":"Developers setting a relative override in .env or shell rc files, or using '~' assuming it gets expanded (expansion may not happen before PathBuf::from).","solutions":["Set ASTRID_HOME to an absolute path starting with '/'","Replace '~' with the expanded home directory before assigning the variable"],"exampleFix":"// before\nexport ASTRID_HOME=.astrid\n// after\nexport ASTRID_HOME=/home/user/.astrid","handlingStrategy":"validation","validationCode":"if let Some(home) = std::env::var(\"ASTRID_HOME\").ok().as_deref() {\n    assert!(std::path::Path::new(home).is_absolute(), \"ASTRID_HOME must be absolute\");\n}","typeGuard":"fn absolute_env(v: &str) -> Option<std::path::PathBuf> {\n    std::env::var(v).ok()\n        .map(std::path::PathBuf::from)\n        .filter(|p| p.is_absolute())\n}","tryCatchPattern":"match dirs_result {\n    Err(e) if e.kind() == io::ErrorKind::InvalidInput => {\n        eprintln!(\"Set ASTRID_HOME to an absolute path\");\n    },\n    other => other?,\n}","preventionTips":["Always export absolute paths for ASTRID_HOME","Expand '~' in wrappers before setting the variable","Test service configs with a clean environment"],"tags":["env-var","path","config"],"backgroundTag":"invalid-env-var-value","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"}