{"record":{"id":"073e033d562efdc3","repo":"jdx/mise","slug":"failed-to-uninstall-old-version-of","errorCode":null,"errorMessage":"Failed to uninstall old version of {}: {}","messagePattern":"Failed to uninstall old version of (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cli/upgrade.rs","lineNumber":716,"sourceCode":"                    .map(|tv| (format!(\"{}@{}\", tv.ba().short, tv.version), tv.style())),\n            );\n            for old_tv in immediate {\n                let key = format!(\"{}@{}\", old_tv.ba().short, old_tv.version);\n                let tool = progress\n                    .as_ref()\n                    .and_then(|progress| progress.start_tool(&key));\n                let pr = match &tool {\n                    Some(tool) => tool.reporter(),\n                    None => mpr.add(&format!(\"uninstall {}\", old_tv.style())),\n                };\n                let result = self\n                    .uninstall_old_version(config, &old_tv, pr.as_ref())\n                    .await;\n                if let Some(tool) = &tool {\n                    tool.complete(result.as_ref().err().map(|e| e.to_string()).as_deref());\n                }\n                match result {\n                    Err(e) => warn!(\n                        \"Failed to uninstall old version of {}: {}\",\n                        old_tv.ba().short,\n                        e\n                    ),\n                    Ok(()) => {\n                        if let Err(err) = crate::tool_purgatory::forget_path(&old_tv.install_path())\n                        {\n                            warn!(\"failed to clear tool purgatory entry: {err:#}\");\n                        }\n                    }\n                }\n            }\n            if let Some(progress) = progress.as_mut() {\n                progress.finish(vec![]);\n            }\n        }\n\n        mpr.finish_progress();","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/upgrade.rs#L698-L734","documentation":"During `mise upgrade`, after installing the new version, mise attempts to uninstall the previous version via `uninstall_old_version`. If that cleanup fails it logs \"Failed to uninstall old version of {tool}: {cause}\" with `warn!` — the upgrade itself succeeded; only the old-version cleanup failed, so execution continues.","triggerScenarios":"`mise upgrade <tool>` where the new version installs fine but removing the old install path fails (locked files, permission issues, or the `tool_purgatory::forget_path` cleanup after removal errors).","commonSituations":"Old version's binary still running during upgrade; manually deleted old install dirs leaving inconsistent state; Windows file locking; disk/permission problems.","solutions":["Treat it as non-fatal: verify with `mise ls` and manually remove the old version with `mise uninstall <tool>@<old-version>`.","Close processes using the old install path and re-run `mise upgrade` or `mise uninstall`.","Check the warned cause for permission issues and fix ownership of the installs directory.","Ignore if the old version was already gone — cleanup is best-effort."],"exampleFix":"// before\nmise upgrade node   # warns: Failed to uninstall old version of node: ...\n// after\nmise uninstall node@20.0.0  # remove stale version manually\nmise ls","handlingStrategy":"try-catch","validationCode":"mise ls <tool>  # check installed versions before upgrading","typeGuard":null,"tryCatchPattern":"let out = Command::new(\"mise\").args([\"upgrade\", tool]).output()?;\nif !out.status.success() || String::from_utf8_lossy(&out.stderr).contains(\"Failed to uninstall old version\") {\n    // non-fatal: manually clean the old version\n    Command::new(\"mise\").args([\"uninstall\", &format!(\"{tool}@{old}\")]).status()?;\n}","preventionTips":["Treat upgrade cleanup warnings as non-fatal and reconcile with `mise ls`.","Stop running tool binaries before upgrading.","Keep install directories writable and untouched by external tooling."],"tags":["rust","cli","upgrade","cleanup"],"backgroundTag":"resource-not-found","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}