Skip to content

Commit 6745cd9

Browse files
committed
uninstalls toolchains prior to deleting the rustup home folder
1 parent fe90448 commit 6745cd9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Diff for: src/cli/rustup_mode.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub fn main() -> Result<utils::ExitCode> {
179179
("man", Some(m)) => man(cfg, m)?,
180180
("self", Some(c)) => match c.subcommand() {
181181
("update", Some(_)) => self_update::update(cfg)?,
182-
("uninstall", Some(m)) => self_uninstall(m)?,
182+
("uninstall", Some(m)) => self_uninstall(cfg, m)?,
183183
(_, _) => unreachable!(),
184184
},
185185
("set", Some(c)) => match c.subcommand() {
@@ -1590,10 +1590,10 @@ fn man(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
15901590
Ok(utils::ExitCode(0))
15911591
}
15921592

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

1596-
self_update::uninstall(no_prompt)
1596+
self_update::uninstall(cfg, no_prompt)
15971597
}
15981598

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

Diff for: src/cli/self_update.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ fn _install_selection<'a>(
903903
})
904904
}
905905

906-
pub(crate) fn uninstall(no_prompt: bool) -> Result<utils::ExitCode> {
906+
pub(crate) fn uninstall(cfg: &Cfg, no_prompt: bool) -> Result<utils::ExitCode> {
907907
if NEVER_SELF_UPDATE {
908908
err!("self-uninstall is disabled for this build of rustup");
909909
err!("you should probably use your system package manager to uninstall rustup");
@@ -926,6 +926,13 @@ pub(crate) fn uninstall(no_prompt: bool) -> Result<utils::ExitCode> {
926926
}
927927
}
928928

929+
info!("removing toolchains");
930+
let toolchains = cfg.list_toolchains()?;
931+
for toolchain in toolchains {
932+
let toolchain = cfg.get_toolchain(&toolchain, false)?;
933+
toolchain.remove()?;
934+
}
935+
929936
info!("removing rustup home");
930937

931938
// Delete RUSTUP_HOME

0 commit comments

Comments
 (0)