{"record":{"id":"1230238a0c78eda1","repo":"Hmbown/CodeWhale","slug":"the-codewhale-bundle-is-still-installed-in-dsh-pro","errorCode":null,"errorMessage":"the Codewhale bundle is still installed in DSH profile `{}`; run `{CLI_COMMAND} remove-bundle` first","messagePattern":"the Codewhale bundle is still installed in DSH profile `(.+?)`; run `(.+?) remove-bundle` first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/integrations/dsh/mod.rs","lineNumber":577,"sourceCode":"        identity_summary: Some(identity_summary(&record.identity)),\n        permission_mode: Some(record.identity.permission_mode.as_str().to_string()),\n        note: None,\n    });\n    doc.current = Some(record.clone());\n    doc.save(&paths.receipt)?;\n    crate::audit::log_sensitive_event(\n        &format!(\"integration.dsh.{}\", event.as_str()),\n        serde_json::json!({ \"overlay_path\": paths.overlay.display().to_string() }),\n    );\n    Ok(record)\n}\n\n/// Delete only Codewhale-owned files; keep the receipt history with a\n/// terminal `remove` entry. Never touches `$DSH_HOME`.\npub(crate) fn remove(paths: &DshPaths) -> Result<Vec<PathBuf>> {\n    let mut doc = DshReceiptDocument::load(&paths.receipt)?;\n    if doc.current.as_ref().is_some_and(|r| r.bundle.is_some()) {\n        anyhow::bail!(\n            \"the Codewhale bundle is still installed in DSH profile `{}`; run `{CLI_COMMAND} remove-bundle` first\",\n            bundle::BUNDLE_PROFILE\n        );\n    }\n    let mut removed = Vec::new();\n    for path in [&paths.overlay, &paths.skin, &paths.skin_preview] {\n        match std::fs::remove_file(path) {\n            Ok(()) => removed.push(path.clone()),\n            Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}\n            Err(error) => return Err(error).with_context(|| format!(\"remove {}\", path.display())),\n        }\n    }\n    let previous = doc.current.take();\n    let now = now_rfc3339();\n    doc.push(DshReceiptEntry {\n        event: DshReceiptEvent::Remove,\n        at: now,\n        codewhale_version: codewhale_version(),","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/integrations/dsh/mod.rs#L559-L595","documentation":"remove deletes only Codewhale-owned files (overlay, skin, skin preview) while keeping receipt history. If the receipt's current record still shows the Codewhale bundle installed in the dsh profile, remove refuses and instructs the user to run remove-bundle first, since deleting the files while the plugin remains linked would leave dsh in a broken state.","triggerScenarios":"Calling `remove` (disconnect) while the current receipt record has bundle.is_some() — i.e. install-bundle succeeded and the bundle is still registered in BUNDLE_PROFILE.","commonSituations":"User tries `codewhale dsh remove` without first running `remove-bundle`; a previous remove-bundle failed partway leaving the receipt showing the bundle installed.","solutions":["Run `codewhale dsh remove-bundle` first, then `remove`","If remove-bundle keeps failing, fix the underlying dsh plugin remove error (see its excerpt)","Manually verify with `dsh plugin list` that the bundle is gone, then clean the receipt state per docs"],"exampleFix":"// before\ncodewhale dsh remove          # fails: bundle still installed\n// after\ncodewhale dsh remove-bundle\ncodewhale dsh remove","handlingStrategy":"validation","validationCode":"let doc = DshReceiptDocument::load(&paths.receipt)?;\nif doc.current.as_ref().is_some_and(|r| r.bundle.is_some()) {\n    eprintln!(\"run `codewhale dsh remove-bundle` before remove\");\n}","typeGuard":"fn bundle_still_installed(record: &DshConnectionRecord) -> bool {\n    record.bundle.is_some()\n}","tryCatchPattern":"match dsh_remove() {\n    Err(e) if e.to_string().contains(\"still installed\") => {\n        dsh_remove_bundle()?;\n        dsh_remove()?;\n    }\n    r => r,\n}","preventionTips":["Follow the documented lifecycle order: remove-bundle, then remove","Check the receipt's bundle field before any uninstall","Retry failed remove-bundle operations before proceeding"],"tags":["dsh-lifecycle","ordering","bundle"],"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"}