Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when tools are missing and allow to override #1337

Merged
merged 3 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/rustup-cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ fn show_channel_updates(cfg: &Cfg, toolchains: Vec<(String, rustup::Result<Updat
Ok(())
}

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

let toolchains = try!(cfg.update_all_channels());
let toolchains = try!(cfg.update_all_channels(force_update));

if toolchains.is_empty() {
info!("no updatable toolchains installed");
Expand Down
14 changes: 11 additions & 3 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ pub fn cli() -> App<'static, 'static> {
.help("Don't perform self update when running the `rustup` command")
.long("no-self-update")
.takes_value(false)
.hidden(true)))
.hidden(true))
.arg(Arg::with_name("force")
.help("Force an update, even if some components are missing")
.long("force")
.takes_value(false)))
.subcommand(SubCommand::with_name("default")
.about("Set the default toolchain")
.after_help(DEFAULT_HELP)
Expand Down Expand Up @@ -462,7 +466,7 @@ fn update(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
let toolchain = try!(cfg.get_toolchain(name, false));

let status = if !toolchain.is_custom() {
Some(try!(toolchain.install_from_dist()))
Some(try!(toolchain.install_from_dist(m.is_present("force"))))
} else if !toolchain.exists() {
return Err(ErrorKind::ToolchainNotInstalled(toolchain.name().to_string()).into());
} else {
Expand All @@ -475,7 +479,11 @@ fn update(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
}
}
} else {
try!(common::update_all_channels(cfg, !m.is_present("no-self-update") && !self_update::NEVER_SELF_UPDATE));
try!(common::update_all_channels(
cfg,
!m.is_present("no-self-update") && !self_update::NEVER_SELF_UPDATE,
m.is_present("force"),
));
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/rustup-cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ fn maybe_install_rust(toolchain_str: &str, default_host_triple: &str, verbose: b
// Set host triple first as it will affect resolution of toolchain_str
try!(cfg.set_default_host_triple(default_host_triple));
let toolchain = try!(cfg.get_toolchain(toolchain_str, false));
let status = try!(toolchain.install_from_dist());
let status = try!(toolchain.install_from_dist(false));
try!(cfg.set_default(toolchain_str));
println!("");
try!(common::show_channel_update(cfg, toolchain_str, Ok(status)));
Expand Down
20 changes: 12 additions & 8 deletions src/rustup-dist/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
toolchain: &ToolchainDesc,
prefix: &InstallPrefix,
add: &[Component],
remove: &[Component])
remove: &[Component],
force_update: bool)
-> Result<Option<String>> {

let fresh_install = !prefix.path().exists();
Expand All @@ -472,7 +473,8 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
toolchain,
prefix,
add,
remove);
remove,
force_update);

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

pub fn update_from_dist_<'a>(download: DownloadCfg<'a>,
update_hash: Option<&Path>,
toolchain: &ToolchainDesc,
prefix: &InstallPrefix,
add: &[Component],
remove: &[Component])
-> Result<Option<String>> {
update_hash: Option<&Path>,
toolchain: &ToolchainDesc,
prefix: &InstallPrefix,
add: &[Component],
remove: &[Component],
force_update: bool)
-> Result<Option<String>> {

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