{"record":{"id":"1531020df238de39","repo":"astrid-runtime/astrid","slug":"legacy-capsule-authority-root-is-not-a-regular-dir","errorCode":null,"errorMessage":"legacy capsule authority root is not a regular directory: {}","messagePattern":"legacy capsule authority root is not a regular directory: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/authority/leftover.rs","lineNumber":233,"sourceCode":"    }\n    if matches.len() == 1 {\n        Ok(Some(matches.remove(0)))\n    } else {\n        Ok(None)\n    }\n}\n\nfn active_receipt_files(home: &AstridHome) -> anyhow::Result<Vec<PathBuf>> {\n    let directory = home.etc_dir().join(AUTHORITY_RECEIPT_DIR);\n    let metadata = match fs::symlink_metadata(&directory) {\n        Ok(metadata) => metadata,\n        Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),\n        Err(error) => {\n            return Err(error).with_context(|| format!(\"inspect {}\", directory.display()));\n        },\n    };\n    if metadata.file_type().is_symlink() || !metadata.is_dir() {\n        bail!(\n            \"legacy capsule authority root is not a regular directory: {}\",\n            directory.display()\n        );\n    }\n    astrid_core::platform_fs::verify_no_redirects(&directory).with_context(|| {\n        format!(\n            \"verify legacy capsule authority root {}\",\n            directory.display()\n        )\n    })?;\n    let mut paths = Vec::new();\n    let mut entries = fs::read_dir(&directory)\n        .with_context(|| format!(\"read legacy capsule authority root {}\", directory.display()))?\n        .collect::<Result<Vec<_>, _>>()\n        .with_context(|| format!(\"read legacy capsule authority root {}\", directory.display()))?;\n    entries.sort_by_key(fs::DirEntry::file_name);\n    for entry in entries {\n        let path = entry.path();","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/authority/leftover.rs#L215-L251","documentation":"active_receipt_files enumerates the legacy capsule authority root, but first verifies via symlink_metadata that the root itself is a plain directory (not a symlink or other file type). If it is not, the library throws this error rather than traversing a redirected or unexpected filesystem object — a security/integrity guard for the authority directory.","triggerScenarios":"Calling unique_relocated_receipt → active_receipt_files when the authority root path (leftover.rs:233) is a symlink or a regular file instead of a directory: typically the whole ~/.astrid (or authority) directory was symlinked by a dotfile manager, or a file was created at that path.","commonSituations":"chezmoi/stow managing the .astrid directory via symlink; a misconfigured ASTRID_HOME pointing at a file; leftover junk file created at the authority path by a buggy script.","solutions":["Replace the symlink with a real directory: rm the symlink, mkdir the path, and copy the receipts back","Point ASTRID_HOME (or the workspace config) at a real directory instead of a symlinked or file path","Exclude the authority directory from dotfile-manager symlinking and manage its contents individually","Inspect with ls -la to confirm what exists at the path before recreating it"],"exampleFix":"// before\n$ ls -l ~/.astrid/authority\nauthority -> /dotfiles/authority\n// after\n$ rm ~/.astrid/authority\n$ mkdir ~/.astrid/authority\n$ cp /dotfiles/authority/* ~/.astrid/authority/\n$ astrid migrate","handlingStrategy":"validation","validationCode":"let md = std::fs::symlink_metadata(authority_root)?;\nif md.is_symlink() || !md.is_dir() {\n    anyhow::bail!(\"authority root must be a real directory: {}\", authority_root.display());\n}","typeGuard":"fn is_real_directory(p: &Path) -> bool {\n    std::fs::symlink_metadata(p).map(|m| !m.is_symlink() && m.is_dir()).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Configure ASTRID_HOME to point at a genuine directory, never a symlink or file","Exclude the entire .astrid tree from symlink-based dotfile management","After restoring from backups, stat the authority path before running commands"],"tags":["filesystem","symlink","security","directory"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}