{"record":{"id":"bb84a0190356d839","repo":"astrid-runtime/astrid","slug":"the-unix-astrid-home-is-resolved-from-home","errorCode":null,"errorMessage":"the Unix Astrid home is resolved from HOME","messagePattern":"the Unix Astrid home is resolved from HOME","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/astrid-core/src/platform_fs.rs","lineNumber":101,"sourceCode":"/// Return the platform's private per-user Astrid root.\n///\n/// Unix resolution remains in [`crate::dirs::AstridHome`] because its existing\n/// `$HOME/.astrid` contract must not move. Windows uses the `LocalAppData` known\n/// folder and never falls back to the current directory or a shared root.\n///\n/// # Errors\n///\n/// Returns an error if Windows cannot resolve a per-user `LocalAppData` folder or\n/// if that folder is not a local absolute path.\npub fn default_astrid_home_root() -> io::Result<PathBuf> {\n    #[cfg(windows)]\n    {\n        windows::default_astrid_home_root()\n    }\n\n    #[cfg(not(windows))]\n    {\n        Err(io::Error::new(\n            io::ErrorKind::Unsupported,\n            \"the Unix Astrid home is resolved from HOME\",\n        ))\n    }\n}\n\n/// Create a security-sensitive directory and enforce the platform's private\n/// access policy.\n///\n/// Unix keeps Astrid's existing owner-only `0700` behavior. Windows installs a\n/// protected DACL containing only the current user, `LocalSystem`, and the local\n/// Administrators group, with inheritable full-control entries for children.\n///\n/// # Errors\n///\n/// Returns an error when the path cannot be created, is redirected through a\n/// symlink or reparse point, or cannot be made private.\npub fn ensure_private_directory(path: &Path) -> io::Result<()> {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-core/src/platform_fs.rs#L83-L119","documentation":"On non-Windows targets, default_astrid_home_root() deliberately returns io::ErrorKind::Unsupported. The Unix Astrid home follows the established `$HOME/.astrid` contract, which is resolved by crate::dirs::AstridHome, so this function refuses to compute an alternative root. It exists only to give Windows a per-user LocalAppData root.","triggerScenarios":"Calling crates/astrid-core/src/platform_fs.rs::default_astrid_home_root() on any non-Windows target (Unix, macOS, or other cfg(not(windows)) builds).","commonSituations":"Portable code that calls the same home-root helper on every platform instead of branching; tests or tooling that assume one cross-platform API; code written against Windows behavior then compiled on Unix.","solutions":["On Unix, resolve the home via crate::dirs::AstridHome (the $HOME/.astrid contract) instead of this function.","Branch on cfg!(windows) and only call default_astrid_home_root() on Windows.","If you need a fallback, read the HOME environment variable explicitly and join \".astrid\"."],"exampleFix":"// before\nlet root = platform_fs::default_astrid_home_root()?;\n// after\nlet root = if cfg!(windows) {\n    platform_fs::default_astrid_home_root()?\n} else {\n    dirs::home_dir().ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, \"HOME not set\"))?.join(\".astrid\")\n};","handlingStrategy":"fallback","validationCode":"let root = if cfg!(windows) {\n    platform_fs::default_astrid_home_root()\n} else {\n    std::env::var(\"HOME\").map(|h| std::path::PathBuf::from(h).join(\".astrid\"))\n        .map_err(|_| io::Error::new(io::ErrorKind::NotFound, \"HOME not set\"))\n};","typeGuard":"fn is_windows() -> bool { cfg!(windows) }","tryCatchPattern":"match platform_fs::default_astrid_home_root() {\n    Ok(root) => root,\n    Err(e) if e.kind() == io::ErrorKind::Unsupported => dirs::home_dir().unwrap().join(\".astrid\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Branch on platform before resolving the Astrid home","Use crate::dirs::AstridHome on Unix for the $HOME/.astrid contract","Never call Windows-only helpers in shared code paths without cfg guards"],"tags":["io","platform-specific","home-directory"],"backgroundTag":"unsupported-platform","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}