Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions e2e/cli/test_uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ assert_contains "mise ls --installed dummy" "1.0.0"
# Test: --dry-run-code should exit 0 when the tool is not installed
mise uninstall dummy@1.0.0
assert_succeed "mise uninstall dummy@1.0.0 --dry-run-code 2>&1"

# Test: a dry run reports each version once, naming every path it would remove
mise i dummy@1.0.0 dummy@1.1.0
out="$(mise uninstall --all --dry-run dummy 2>&1)"
assert_contains_text "$out" "dummy@1.0.0"
assert_contains_text "$out" "dummy@1.1.0"
assert_contains_text "count=$(grep -c 'dummy@1.0.0 .*remove' <<<"$out")" "count=1"
Comment thread
jdx marked this conversation as resolved.
Resolved
13 changes: 10 additions & 3 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4468,12 +4468,15 @@ pub trait Backend: Debug + Send + Sync {
if !dryrun {
self.uninstall_version_impl(config, pr, tv).await?;
}
let rmdir = |dir: &Path| {
// A dry run reports once, after every path is known: each message on a live
// progress row is drawn as a row of its own, so reporting per path repeated the row.
let mut would_remove: Vec<String> = vec![];
let mut rmdir = |dir: &Path| {
if dryrun {
// Not `exists()`, which resolves a link: a dry run has to name the entry the real
// run would remove, and a link whose target is gone is one of them.
if entry_exists(dir) {
pr.set_message(format!("remove {}", display_path(dir)));
would_remove.push(display_path(dir));
}
return Ok(());
}
Expand All @@ -4494,7 +4497,11 @@ pub trait Backend: Debug + Send + Sync {
rmdir(&tv.download_path())?;
}
rmdir(&tv.cache_path())?;
if !dryrun {
if dryrun {
if !would_remove.is_empty() {
pr.set_message(format!("remove {}", would_remove.join(", ")));
}
} else {
self.cleanup_empty_installs_dir();
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions src/cli/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ impl Uninstall {
warn!("{} is not installed", tv.style());
continue;
}
// `--all` lists what is installed, but a configured request (`27`) can stand
// for an installation under another name (`temurin-27.0.0+35`) and so name
// a directory that does not exist. Only stale cache under that name would be
// reported, as if a second installation were being removed.
if self.all && !file::entry_exists(tv.install_path()) {
debug!("{} has no installation to remove", tv.style());
continue;
}
to_remove.push((plugin, tv));
}
let has_work = !to_remove.is_empty();
Expand Down
Loading