{"record":{"id":"3316d00a32ea041d","repo":"astrid-runtime/astrid","slug":"failed-to-resolve-astrid-home-e","errorCode":null,"errorMessage":"Failed to resolve Astrid home: {e}","messagePattern":"Failed to resolve Astrid home: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/config.rs","lineNumber":58,"sourceCode":"                for path in &resolved.loaded_files {\n                    println!(\"  - {path}\");\n                }\n            }\n            Ok(())\n        },\n        Err(e) => {\n            eprintln!(\"Configuration error: {e}\");\n            std::process::exit(1);\n        },\n    }\n}\n\n/// Open the global runtime config file (`~/.astrid/etc/config.toml`)\n/// in `$EDITOR` (falling back to `$VISUAL`, then `vi`). Creates the\n/// file if missing so the editor opens on a real path.\npub(crate) fn edit_config() -> Result<()> {\n    let home = astrid_core::dirs::AstridHome::resolve()\n        .map_err(|e| anyhow::anyhow!(\"Failed to resolve Astrid home: {e}\"))?;\n    let path = home.config_path();\n    if !path.exists() {\n        if let Some(parent) = path.parent() {\n            std::fs::create_dir_all(parent)?;\n        }\n        std::fs::write(&path, \"# Astrid runtime configuration\\n\")?;\n    }\n    let editor = std::env::var(\"EDITOR\")\n        .ok()\n        .or_else(|| std::env::var(\"VISUAL\").ok())\n        .unwrap_or_else(|| \"vi\".to_string());\n    let status = std::process::Command::new(&editor)\n        .arg(&path)\n        .status()\n        .map_err(|e| anyhow::anyhow!(\"Failed to launch '{editor}': {e}\"))?;\n    if !status.success() {\n        anyhow::bail!(\"editor '{editor}' exited with non-zero status\");\n    }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/config.rs#L40-L76","documentation":"Thrown by `edit_config` when `astrid_core::dirs::AstridHome::resolve()` fails, i.e. the Astrid home directory (~/.astrid or $ASTRID_HOME) cannot be determined or created. The CLI needs the home root to locate `~/.astrid/etc/config.toml` before opening it in an editor. This is an environment/configuration resolution failure, not a file-format problem.","triggerScenarios":"Running `astrid config edit` when neither $ASTRID_HOME nor a usable home directory can be resolved (e.g. unset/invalid HOME, $ASTRID_HOME pointing at an unwritable or invalid path, or the resolver's create/verify step fails).","commonSituations":"Running under a service account or container with no HOME set; ASTRID_HOME set to a read-only mount; typo'd ASTRID_HOME path with permission-denied on create.","solutions":["Ensure HOME is set and writable (`echo $HOME`), or run as a user with a valid home directory.","Set ASTRID_HOME explicitly to an existing, writable directory: `export ASTRID_HOME=/path/to/astrid-home`.","Check the wrapped {e} text for the concrete cause (permission denied, path invalid) and fix that path's permissions.","Pre-create the home directory: `mkdir -p ~/.astrid/etc`."],"exampleFix":"// before (shell)\nastrid config edit\n// after (shell)\nexport ASTRID_HOME=\"$HOME/.astrid\"\nmkdir -p \"$ASTRID_HOME/etc\"\nastrid config edit","handlingStrategy":"validation","validationCode":"let home = std::env::var(\"ASTRID_HOME\")\n    .or_else(|_| std::env::var(\"HOME\"))\n    .map_err(|_| anyhow!(\"ASTRID_HOME or HOME must be set before `astrid config edit`\"))?;\nif !std::path::Path::new(&home).is_dir() {\n    return Err(anyhow!(\"astrid home {home} does not exist\"));\n}","typeGuard":null,"tryCatchPattern":"match AstridHome::resolve() {\n    Err(e) => eprintln!(\"home resolve failed: {e}; set ASTRID_HOME to a writable dir\"),\n    Ok(home) => edit(home.config_path()),\n}","preventionTips":["Set ASTRID_HOME explicitly in shell profiles and container images.","Ensure HOME is set for service accounts and CI runners.","Keep the astrid home on a local, writable filesystem (not NFS or read-only mounts).","Run `mkdir -p ~/.astrid/etc` during environment provisioning."],"tags":["config","filesystem","environment","cli"],"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"}