{"record":{"id":"15527de544349228","repo":"astrid-runtime/astrid","slug":"cannot-remove-name-it-is-the-sole-provider-of","errorCode":null,"errorMessage":"Cannot remove '{name}': it is the sole provider of '{}' which is required by '{}'. Use --force to override.","messagePattern":"Cannot remove '(.+?)': it is the sole provider of '(.+?)' which is required by '(.+?)'\\. Use --force to override\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/capsule/remove.rs","lineNumber":201,"sourceCode":"\n    if !target_dir.exists() {\n        bail!(\"Capsule '{name}' is not installed.\");\n    }\n\n    let target_meta = super::meta::read_meta(&target_dir);\n\n    // Scan once, reuse for both dependency check and binary cleanup\n    let all_capsules =\n        astrid_capsule_install::meta::scan_installed_capsules_in_home_for_in_workspace(\n            home,\n            principal,\n            workspace_root,\n            crate::workspace_layout::current(),\n        )?;\n\n    // Dependency safety check (skip with --force)\n    if !force && let Some(block) = check_removal_safety(name, target_meta.as_ref(), &all_capsules) {\n        bail!(\n            \"Cannot remove '{name}': it is the sole provider of '{}' \\\n             which is required by '{}'. Use --force to override.\",\n            block.capability,\n            block.dependent,\n        );\n    }\n\n    Ok(())\n}\n\n/// A blocked removal: the target capsule is the sole provider of a capability\n/// that another capsule requires.\nstruct RemovalBlocked {\n    capability: String,\n    dependent: String,\n}\n\n/// Check whether removing `target_name` would leave any required capability","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/capsule/remove.rs#L183-L219","documentation":"Before removing a workspace capsule, the CLI runs check_removal_safety against all installed capsules. If the target is the sole provider of a capability that another installed capsule depends on, removal would break that dependent, so it bails and names the capability and dependent capsule, suggesting --force. This guards the workspace dependency graph from accidental breakage.","triggerScenarios":"astrid capsule remove <name> --workspace without --force when another installed capsule's dependencies resolve to this capsule as the only provider of some capability.","commonSituations":"Removing a shared utility/library capsule that several agents' capsules depend on; cleaning up 'unused-looking' capsules in a shared workspace; scripted bulk removals that ignore the graph.","solutions":["Remove or update the dependent capsule first so it no longer needs the capability.","If you accept the breakage, re-run with --force: astrid capsule remove <name> --workspace --force.","Inspect the dependency report (capsule list / show) to see which capsules consume the capability before deciding."],"exampleFix":"// before\nastrid capsule remove logging-lib --workspace            // blocked: required by 'ingest'\n// after\nastrid capsule remove logging-lib --workspace --force    // explicit override\n// or: remove/update 'ingest' first","handlingStrategy":"validation","validationCode":"// dry-run the dependency check before removing\nif let Some(block) = check_removal_safety(name, meta, &all_capsules) {\n    eprintln!(\"would block: {} needed by {}\", block.capability, block.dependent);\n}","typeGuard":"fn is_dependency_block(e: &anyhow::Error) -> bool {\n    e.to_string().contains(\"sole provider\")\n}","tryCatchPattern":"if let Err(e) = remove_capsule(...).await {\n    if is_dependency_block(&e) {\n        // surface block.capability/block.dependent, require explicit --force\n    } else { return Err(e); }\n}","preventionTips":["Inspect dependents with capsule show before removing shared capsules.","Never pass --force blindly in scripts; prompt the operator.","Plan capability ownership so shared capsules have explicit maintainers."],"tags":["dependencies","capsule","safety-check"],"backgroundTag":"dependency-conflict","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"}