{"record":{"id":"d1ee8daf019ad9f8","repo":"Hmbown/CodeWhale","slug":"plugin-selector-is-enabled-disable-it-first-w","errorCode":null,"errorMessage":"plugin `{selector}` is enabled; disable it first with /plugin disable {selector}","messagePattern":"plugin `(.+?)` is enabled; disable it first with /plugin disable (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/plugins/mutation.rs","lineNumber":214,"sourceCode":"    })\n}\n\nfn uninstall_plugin(\n    selector: &str,\n    registry: &mut PluginRegistry,\n) -> Result<PluginMutationReceipt> {\n    let plugin = registry\n        .get(selector)\n        .with_context(|| format!(\"Plugin bundle `{selector}` was not found\"))?\n        .clone();\n    if plugin.scope != PluginScope::User {\n        bail!(\n            \"refusing to uninstall the {} bundle `{selector}`; remove it from its own root\",\n            plugin.scope.as_str()\n        );\n    }\n    if plugin.enabled {\n        bail!(\"plugin `{selector}` is enabled; disable it first with /plugin disable {selector}\");\n    }\n    let plugins_dir = user_plugins_dir(registry)?;\n    install::uninstall(plugin.name(), &plugins_dir)?;\n    registry\n        .prune_state_entry(selector)\n        .map_err(anyhow::Error::msg)?;\n    Ok(PluginMutationReceipt {\n        name: plugin.name().to_string(),\n        path: None,\n        content_hash: None,\n        installed_content_hash: None,\n        outcome: PluginMutationOutcome::Uninstalled,\n    })\n}\n\nfn blocked(host: String, needs_approval: bool) -> PluginMutationReceipt {\n    PluginMutationReceipt {\n        name: String::new(),","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/plugins/mutation.rs#L196-L232","documentation":"Before uninstalling, `uninstall_plugin` requires the bundle to be disabled. If `plugin.enabled` is true it bails and tells the user the exact `/plugin disable <selector>` command to run first. This prevents deleting a bundle that is actively loaded.","triggerScenarios":"Calling `/plugin uninstall <selector>` on a user-scope bundle while it is still enabled in the registry.","commonSituations":"Uninstalling during cleanup without realizing the plugin is active; scripted uninstall loops that do not disable first.","solutions":["Run `/plugin disable <selector>` first, then `/plugin uninstall <selector>`","In scripts, call the disable mutation before the uninstall mutation and check its receipt"],"exampleFix":"// before\n/plugin uninstall myplugin      # enabled -> refuse\n// after\n/plugin disable myplugin\n/plugin uninstall myplugin","handlingStrategy":"validation","validationCode":"let plugin = registry.get(selector)?;\nif plugin.enabled {\n    eprintln!(\"disable {} before uninstalling: /plugin disable {}\", selector, selector);\n    return;\n}","typeGuard":null,"tryCatchPattern":"match uninstall_plugin(selector, registry) {\n    Err(e) if e.to_string().contains(\"disable it first\") => {\n        execute_disable(selector)?;   // /plugin disable <selector>\n        uninstall_plugin(selector, registry)?;\n    }\n    other => other?,\n}","preventionTips":["Always disable before uninstall in scripts","Wrap uninstall in a disable-then-uninstall helper","Surface enabled state in any uninstall UI/confirmation"],"tags":["plugins","uninstall","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}