Skip to content

Commit afbeeaf

Browse files
committed
Auto merge of #1337 - nrc:ui-missing-tool, r=alexcrichton
Warn when tools are missing and allow to override Closes #1277 Idea here is to not update if the RLS is missing (for example). There was actually functionality to do this already, but it was not catching the RLS and Rustfmt since they were missing in an unexpected way. The second commit adds `rustup update --force` to update even if some components are missing r? @alexcrichton
2 parents 38e1d3a + dcf0f9d commit afbeeaf

File tree

10 files changed

+308
-190
lines changed

10 files changed

+308
-190
lines changed

src/rustup-cli/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ fn show_channel_updates(cfg: &Cfg, toolchains: Vec<(String, rustup::Result<Updat
189189
Ok(())
190190
}
191191

192-
pub fn update_all_channels(cfg: &Cfg, self_update: bool) -> Result<()> {
192+
pub fn update_all_channels(cfg: &Cfg, self_update: bool, force_update: bool) -> Result<()> {
193193

194-
let toolchains = try!(cfg.update_all_channels());
194+
let toolchains = try!(cfg.update_all_channels(force_update));
195195

196196
if toolchains.is_empty() {
197197
info!("no updatable toolchains installed");

src/rustup-cli/rustup_mode.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ pub fn cli() -> App<'static, 'static> {
144144
.help("Don't perform self update when running the `rustup` command")
145145
.long("no-self-update")
146146
.takes_value(false)
147-
.hidden(true)))
147+
.hidden(true))
148+
.arg(Arg::with_name("force")
149+
.help("Force an update, even if some components are missing")
150+
.long("force")
151+
.takes_value(false)))
148152
.subcommand(SubCommand::with_name("default")
149153
.about("Set the default toolchain")
150154
.after_help(DEFAULT_HELP)
@@ -462,7 +466,7 @@ fn update(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
462466
let toolchain = try!(cfg.get_toolchain(name, false));
463467

464468
let status = if !toolchain.is_custom() {
465-
Some(try!(toolchain.install_from_dist()))
469+
Some(try!(toolchain.install_from_dist(m.is_present("force"))))
466470
} else if !toolchain.exists() {
467471
return Err(ErrorKind::ToolchainNotInstalled(toolchain.name().to_string()).into());
468472
} else {
@@ -475,7 +479,11 @@ fn update(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
475479
}
476480
}
477481
} else {
478-
try!(common::update_all_channels(cfg, !m.is_present("no-self-update") && !self_update::NEVER_SELF_UPDATE));
482+
try!(common::update_all_channels(
483+
cfg,
484+
!m.is_present("no-self-update") && !self_update::NEVER_SELF_UPDATE,
485+
m.is_present("force"),
486+
));
479487
}
480488

481489
Ok(())

src/rustup-cli/self_update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ fn maybe_install_rust(toolchain_str: &str, default_host_triple: &str, verbose: b
747747
// Set host triple first as it will affect resolution of toolchain_str
748748
try!(cfg.set_default_host_triple(default_host_triple));
749749
let toolchain = try!(cfg.get_toolchain(toolchain_str, false));
750-
let status = try!(toolchain.install_from_dist());
750+
let status = try!(toolchain.install_from_dist(false));
751751
try!(cfg.set_default(toolchain_str));
752752
println!("");
753753
try!(common::show_channel_update(cfg, toolchain_str, Ok(status)));

src/rustup-dist/src/dist.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
462462
toolchain: &ToolchainDesc,
463463
prefix: &InstallPrefix,
464464
add: &[Component],
465-
remove: &[Component])
465+
remove: &[Component],
466+
force_update: bool)
466467
-> Result<Option<String>> {
467468

468469
let fresh_install = !prefix.path().exists();
@@ -472,7 +473,8 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
472473
toolchain,
473474
prefix,
474475
add,
475-
remove);
476+
remove,
477+
force_update);
476478

477479
// Don't leave behind an empty / broken installation directory
478480
if res.is_err() && fresh_install {
@@ -485,12 +487,13 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
485487
}
486488

487489
pub fn update_from_dist_<'a>(download: DownloadCfg<'a>,
488-
update_hash: Option<&Path>,
489-
toolchain: &ToolchainDesc,
490-
prefix: &InstallPrefix,
491-
add: &[Component],
492-
remove: &[Component])
493-
-> Result<Option<String>> {
490+
update_hash: Option<&Path>,
491+
toolchain: &ToolchainDesc,
492+
prefix: &InstallPrefix,
493+
add: &[Component],
494+
remove: &[Component],
495+
force_update: bool)
496+
-> Result<Option<String>> {
494497

495498
let toolchain_str = toolchain.to_string();
496499
let manifestation = try!(Manifestation::open(prefix.clone(), toolchain.target.clone()));
@@ -507,6 +510,7 @@ pub fn update_from_dist_<'a>(download: DownloadCfg<'a>,
507510
(download.notify_handler)(Notification::DownloadedManifest(&m.date, m.get_rust_version().ok()));
508511
return match try!(manifestation.update(&m,
509512
changes,
513+
force_update,
510514
&download,
511515
download.notify_handler.clone())) {
512516
UpdateStatus::Unchanged => Ok(None),

0 commit comments

Comments
 (0)