{"record":{"id":"f0f4005c9047f4f7","repo":"astrid-runtime/astrid","slug":"update-notices-require-an-initialized-astrid-home","errorCode":null,"errorMessage":"update notices require an initialized Astrid home","messagePattern":"update notices require an initialized Astrid home","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/astrid-cli/src/commands/self_update_notice.rs","lineNumber":28,"sourceCode":"    CHECK_TTL_SECS, CURRENT_VERSION, InstallMethod, UpdateChannel, platform_target, resolve_repo,\n    running_binary, update_channel,\n};\n\n#[derive(serde::Serialize, serde::Deserialize)]\nstruct UpdateCache {\n    checked_at: u64,\n    latest_version: String,\n    channel: String,\n}\n\nfn cache_path() -> anyhow::Result<PathBuf> {\n    let home = astrid_core::dirs::AstridHome::resolve()?;\n    cache_path_for(&home)\n}\n\nfn cache_path_for(home: &astrid_core::dirs::AstridHome) -> anyhow::Result<PathBuf> {\n    if home.layout_version()?.as_deref() != Some(astrid_core::dirs::LAYOUT_VERSION) {\n        bail!(\"update notices require an initialized Astrid home\");\n    }\n    Ok(home.var_dir().join(\"update-check.json\"))\n}\n\nfn now_epoch() -> u64 {\n    std::time::SystemTime::now()\n        .duration_since(std::time::UNIX_EPOCH)\n        .map_or(0, |duration| duration.as_secs())\n}\n\npub(super) fn write_cache(channel: UpdateChannel, version: &str) {\n    let cache = UpdateCache {\n        checked_at: now_epoch(),\n        latest_version: version.to_owned(),\n        channel: channel.as_str().to_owned(),\n    };\n    if let Ok(path) = cache_path()\n        && let Ok(json) = serde_json::to_string(&cache)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/self_update_notice.rs#L10-L46","documentation":"cache_path_for only returns the update-notice cache file when the resolved Astrid home reports the current layout version. If the home directory is missing, fresh, or was created by an older/newer layout, the code refuses to cache update notices rather than create state inside an undeclared home. It fails fast so notice caching never implicitly initializes a home directory.","triggerScenarios":"Calling any command that consults update notices before `astrid init` (or equivalent) has created an initialized home, or when ASTRID_HOME points to an empty/new directory, or the home was produced by a different layout version.","commonSituations":"Running astrid in CI or a container with a fresh/empty ASTRID_HOME; users who deleted their home dir; version mismatch after an upgrade that changed the layout version; tests deliberately pointing at a nonexistent home.","solutions":["Initialize the Astrid home first (run the init/setup command or create a session) so its layout version matches LAYOUT_VERSION.","If ASTRID_HOME points at the wrong place, unset or correct the environment variable to the initialized home.","If the home is stale from an old version, re-initialize/migrate it to the current layout."],"exampleFix":"// before\nexport ASTRID_HOME=/tmp/fresh-home   # uninitialized\nastrid doctor                         # error: update notices require an initialized Astrid home\n\n// after\nastrid init                            # or: unset ASTRID_HOME to use the real initialized home\nastrid doctor","handlingStrategy":"fallback","validationCode":"let home = astrid_core::dirs::AstridHome::resolve()?;\nlet initialized = home.layout_version()?.as_deref()\n    == Some(astrid_core::dirs::LAYOUT_VERSION);\nif !initialized { eprintln!(\"home not initialized; skipping update notice cache\"); }","typeGuard":null,"tryCatchPattern":"match cache_path() {\n    Ok(path) => read_notice_cache(&path),\n    Err(_) => Ok(None), // notices are best-effort; degrade silently\n}","preventionTips":["Run the init/setup command before any command that touches update notices.","Keep ASTRID_HOME pointing at an initialized home in CI/containers.","After upgrading Astrid across layout versions, re-initialize or migrate the home."],"tags":["update-notice","home-directory","initialization","layout-version"],"backgroundTag":"missing-required-config","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"}