@@ -474,6 +474,17 @@ This will uninstall all Rust toolchains and data, and remove
474474 } ;
475475}
476476
477+ macro_rules! pre_uninstall_msg_no_modify_path {
478+ ( ) => {
479+ r"# Thanks for hacking in Rust!
480+
481+ This will uninstall all Rust toolchains and data.
482+ Your `PATH` environment variable will not be touched.
483+
484+ "
485+ } ;
486+ }
487+
477488static DEFAULT_UPDATE_ROOT : & str = "https://static.rust-lang.org/rustup" ;
478489
479490fn update_root ( process : & Process ) -> String {
@@ -968,7 +979,11 @@ async fn maybe_install_rust(opts: InstallOpts<'_>, cfg: &mut Cfg<'_>) -> Result<
968979 Ok ( ( ) )
969980}
970981
971- pub ( crate ) fn uninstall ( no_prompt : bool , process : & Process ) -> Result < utils:: ExitCode > {
982+ pub ( crate ) fn uninstall (
983+ no_prompt : bool ,
984+ no_modify_path : bool ,
985+ process : & Process ,
986+ ) -> Result < utils:: ExitCode > {
972987 if cfg ! ( feature = "no-self-update" ) {
973988 error ! ( "self-uninstall is disabled for this build of rustup" ) ;
974989 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<utils::Exi
983998
984999 if !no_prompt {
9851000 writeln ! ( process. stdout( ) . lock( ) ) ?;
986- let msg = format ! (
987- pre_uninstall_msg!( ) ,
988- cargo_home = canonical_cargo_home( process) ?
989- ) ;
1001+ let msg = if no_modify_path {
1002+ pre_uninstall_msg_no_modify_path ! ( ) . to_owned ( )
1003+ } else {
1004+ format ! (
1005+ pre_uninstall_msg!( ) ,
1006+ cargo_home = canonical_cargo_home( process) ?
1007+ )
1008+ } ;
9901009 md ( & mut process. stdout ( ) , msg) ;
9911010 if !common:: confirm ( "\n Continue? (y/N)" , false , process) ? {
9921011 info ! ( "aborting uninstallation" ) ;
@@ -1005,7 +1024,9 @@ pub(crate) fn uninstall(no_prompt: bool, process: &Process) -> Result<utils::Exi
10051024 info ! ( "removing cargo home" ) ;
10061025
10071026 // Remove CARGO_HOME/bin from PATH
1008- do_remove_from_path ( process) ?;
1027+ if !no_modify_path {
1028+ do_remove_from_path ( process) ?;
1029+ }
10091030
10101031 // Delete everything in CARGO_HOME *except* the rustup bin
10111032
0 commit comments