diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 7659c3bf29..b38d7c0477 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1032,13 +1032,25 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { cfg.temp_cfg.clean(); } - if !self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::CheckOnly { - check_rustup_update()?; + match (&self_update_mode, self_update::NEVER_SELF_UPDATE) { + (SelfUpdateMode::CheckOnly, _) | (SelfUpdateMode::Enable, true) => check_rustup_update()?, + (SelfUpdateMode::Disable, _) | (SelfUpdateMode::Enable, false) => {} } - if self_update::NEVER_SELF_UPDATE { + if self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::Enable { + let mut args = crate::process().args_os(); + let arg0 = args.next().map(PathBuf::from); + let arg0 = arg0 + .as_ref() + .and_then(|a| a.to_str()) + .ok_or(CLIError::NoExeName)?; + info!("self-update is disabled for this build of rustup"); - info!("any updates to rustup will need to be fetched with your system package manager") + info!("any updates to rustup will need to be fetched with your system package manager"); + info!( + "to suppress this message, run `{} set auto-self-update disable`", + arg0, + ); } Ok(utils::ExitCode(0)) @@ -1608,16 +1620,19 @@ fn set_profile(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { } fn set_auto_self_update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { - if self_update::NEVER_SELF_UPDATE { + cfg.set_auto_self_update(m.value_of("auto-self-update-mode").unwrap())?; + + if self_update::NEVER_SELF_UPDATE && cfg.get_self_update_mode()? == SelfUpdateMode::Enable { let mut args = crate::process().args_os(); let arg0 = args.next().map(PathBuf::from); let arg0 = arg0 .as_ref() .and_then(|a| a.to_str()) .ok_or(CLIError::NoExeName)?; - warn!("{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",arg0); + warn!("{} is built with the no-self-update feature", arg0); + warn!("setting auto-self-update to enable won't lead to updates being installed"); } - cfg.set_auto_self_update(m.value_of("auto-self-update-mode").unwrap())?; + Ok(utils::ExitCode(0)) }