Skip to content

Commit b14faa4

Browse files
committed
Add more detail error messages when installing with some components has failed
1 parent 67f9e43 commit b14faa4

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/rustup-dist/src/errors.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ use std::io::{self, Write};
55
use std::path::PathBuf;
66
use toml;
77

8+
pub const TOOLSTATE_MSG: &str = "if you require these components, please install and use the latest successful build version, \
9+
which you can find at https://rust-lang-nursery.github.io/rust-toolstate, for example.\n\
10+
rustup install nightly-2018-12-27";
11+
812
error_chain! {
913
links {
1014
Utils(rustup_utils::Error, rustup_utils::ErrorKind);
@@ -127,11 +131,21 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest) -> String {
127131
if same_target {
128132
let mut cs_strs = cs.iter().map(|c| format!("'{}'", c.short_name(manifest)));
129133
let cs_str = cs_strs.join(", ");
130-
let _ = write!(buf, "some components unavailable for download: {}", cs_str);
134+
let _ = write!(
135+
buf,
136+
"some components unavailable for download: {}\n{}",
137+
cs_str,
138+
TOOLSTATE_MSG,
139+
);
131140
} else {
132141
let mut cs_strs = cs.iter().map(|c| c.description(manifest));
133142
let cs_str = cs_strs.join(", ");
134-
let _ = write!(buf, "some components unavailable for download: {}", cs_str);
143+
let _ = write!(
144+
buf,
145+
"some components unavailable for download: {}\n{}",
146+
cs_str,
147+
TOOLSTATE_MSG,
148+
);
135149
}
136150
}
137151

tests/cli-misc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use rustup_mock::clitools::{
1212
expect_timeout_ok, run, set_current_dist_date, this_host_triple, Config, Scenario,
1313
};
1414
use rustup_utils::{raw, utils};
15+
use rustup_dist::errors::{TOOLSTATE_MSG};
1516

1617
use std::env::consts::EXE_SUFFIX;
1718
use std::ops::Add;
@@ -808,7 +809,10 @@ fn update_unavailable_rustc() {
808809
expect_err(
809810
config,
810811
&["rustup", "update", "nightly"],
811-
"some components unavailable for download: 'rustc', 'cargo'",
812+
format!(
813+
"some components unavailable for download: 'rustc', 'cargo'\n{}",
814+
TOOLSTATE_MSG
815+
).as_str(),
812816
);
813817

814818
expect_stdout_ok(config, &["rustc", "--version"], "hash-n-1");

0 commit comments

Comments
 (0)