diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index a3137c6f51..34f267dbc6 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -540,8 +540,13 @@ enum SelfSubcmd { /// Uninstall rustup Uninstall { + /// Disable confirmation prompt #[arg(short = 'y')] no_prompt: bool, + + /// Do not clean up the `PATH` environment variable + #[arg(long)] + no_modify_path: bool, }, /// Upgrade the internal data format @@ -724,7 +729,10 @@ pub async fn main( RustupSubcmd::Man { command, toolchain } => man(cfg, &command, toolchain).await, RustupSubcmd::Self_ { subcmd } => match subcmd { SelfSubcmd::Update => self_update::update(cfg).await, - SelfSubcmd::Uninstall { no_prompt } => self_update::uninstall(no_prompt, process), + SelfSubcmd::Uninstall { + no_prompt, + no_modify_path, + } => self_update::uninstall(no_prompt, no_modify_path, process), SelfSubcmd::UpgradeData => cfg.upgrade_data().map(|_| ExitCode(0)), }, RustupSubcmd::Set { subcmd } => match subcmd { diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 5e1e7b78aa..ee09c72537 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -474,6 +474,17 @@ This will uninstall all Rust toolchains and data, and remove }; } +macro_rules! pre_uninstall_msg_no_modify_path { + () => { + r"# Thanks for hacking in Rust! + +This will uninstall all Rust toolchains and data. +Your `PATH` environment variable will not be touched. + +" + }; +} + static DEFAULT_UPDATE_ROOT: &str = "https://static.rust-lang.org/rustup"; fn update_root(process: &Process) -> String { @@ -968,7 +979,11 @@ async fn maybe_install_rust(opts: InstallOpts<'_>, cfg: &mut Cfg<'_>) -> Result< Ok(()) } -pub(crate) fn uninstall(no_prompt: bool, process: &Process) -> Result { +pub(crate) fn uninstall( + no_prompt: bool, + no_modify_path: bool, + process: &Process, +) -> Result { if cfg!(feature = "no-self-update") { error!("self-uninstall is disabled for this build of rustup"); error!("you should probably use your system package manager to uninstall rustup"); @@ -983,10 +998,14 @@ pub(crate) fn uninstall(no_prompt: bool, process: &Process) -> Result Result +