Skip to content

Commit 600e57b

Browse files
committed
uninstalls toolchains prior to deleting the rustup home folder
1 parent a9e1989 commit 600e57b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/cli/rustup_mode.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn main() -> Result<utils::ExitCode> {
182182
("man", Some(m)) => man(cfg, m)?,
183183
("self", Some(c)) => match c.subcommand() {
184184
("update", Some(_)) => self_update::update(cfg)?,
185-
("uninstall", Some(m)) => self_uninstall(m)?,
185+
("uninstall", Some(m)) => self_uninstall(cfg, m)?,
186186
(_, _) => unreachable!(),
187187
},
188188
("set", Some(c)) => match c.subcommand() {
@@ -1569,10 +1569,10 @@ fn man(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
15691569
Ok(utils::ExitCode(0))
15701570
}
15711571

1572-
fn self_uninstall(m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
1572+
fn self_uninstall(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
15731573
let no_prompt = m.is_present("no-prompt");
15741574

1575-
self_update::uninstall(no_prompt)
1575+
self_update::uninstall(cfg, no_prompt)
15761576
}
15771577

15781578
fn set_default_host_triple(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {

src/cli/self_update.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ fn _install_selection<'a>(
863863
})
864864
}
865865

866-
pub(crate) fn uninstall(no_prompt: bool) -> Result<utils::ExitCode> {
866+
pub(crate) fn uninstall(cfg: &Cfg, no_prompt: bool) -> Result<utils::ExitCode> {
867867
if NEVER_SELF_UPDATE {
868868
err!("self-uninstall is disabled for this build of rustup");
869869
err!("you should probably use your system package manager to uninstall rustup");
@@ -889,6 +889,13 @@ pub(crate) fn uninstall(no_prompt: bool) -> Result<utils::ExitCode> {
889889
}
890890
}
891891

892+
info!("removing toolchains");
893+
let toolchains = cfg.list_toolchains()?;
894+
for toolchain in toolchains {
895+
let toolchain = cfg.get_toolchain(&toolchain, false)?;
896+
toolchain.remove()?;
897+
}
898+
892899
info!("removing rustup home");
893900

894901
// Delete RUSTUP_HOME

0 commit comments

Comments
 (0)