Skip to content

Commit

Permalink
uninstalls toolchains prior to deleting the rustup home folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Darunada committed Feb 25, 2023
1 parent fe90448 commit 6745cd9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub fn main() -> Result<utils::ExitCode> {
("man", Some(m)) => man(cfg, m)?,
("self", Some(c)) => match c.subcommand() {
("update", Some(_)) => self_update::update(cfg)?,
("uninstall", Some(m)) => self_uninstall(m)?,
("uninstall", Some(m)) => self_uninstall(cfg, m)?,
(_, _) => unreachable!(),
},
("set", Some(c)) => match c.subcommand() {
Expand Down Expand Up @@ -1590,10 +1590,10 @@ fn man(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
Ok(utils::ExitCode(0))
}

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

self_update::uninstall(no_prompt)
self_update::uninstall(cfg, no_prompt)
}

fn set_default_host_triple(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
Expand Down
9 changes: 8 additions & 1 deletion src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ fn _install_selection<'a>(
})
}

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

info!("removing toolchains");
let toolchains = cfg.list_toolchains()?;
for toolchain in toolchains {
let toolchain = cfg.get_toolchain(&toolchain, false)?;
toolchain.remove()?;
}

info!("removing rustup home");

// Delete RUSTUP_HOME
Expand Down

0 comments on commit 6745cd9

Please sign in to comment.