diff --git a/src/rustup/config.rs b/src/rustup/config.rs index 1ccca4fa03..87b1b3ccdf 100644 --- a/src/rustup/config.rs +++ b/src/rustup/config.rs @@ -233,7 +233,18 @@ impl Cfg { Ok(s.find_override(path, self.notify_handler.as_ref())) })); if let Some((name, reason_path)) = result { - let toolchain = try!(self.verify_toolchain(&name).chain_err(|| ErrorKind::ToolchainNotInstalled(name.to_string()))); + let toolchain = match self.verify_toolchain(&name) { + Ok(t) => { t }, + Err(Error(ErrorKind::Utils(::rustup_utils::ErrorKind::NotADirectory { .. }), _)) => { + // Strip the confusing NotADirectory error and only mention that the override + // toolchain is not installed. + return Err(ErrorKind::OverrideToolchainNotInstalled(name.to_string()).into()) + }, + Err(e) => return Err(e).chain_err(|| { + ErrorKind::OverrideToolchainNotInstalled(name.to_string()) + }) + + }; return Ok(Some((toolchain, OverrideReason::OverrideDB(reason_path)))); } diff --git a/src/rustup/errors.rs b/src/rustup/errors.rs index 6970676ef1..1a60b6bd42 100644 --- a/src/rustup/errors.rs +++ b/src/rustup/errors.rs @@ -22,6 +22,10 @@ error_chain! { description("toolchain is not installed") display("toolchain '{}' is not installed", t) } + OverrideToolchainNotInstalled(t: String) { + description("override toolchain is not installed") + display("override toolchain '{}' is not installed", t) + } BinaryNotFound(t: String, bin: String) { description("toolchain does not contain binary") display("toolchain '{}' does not have the binary `{}`", t, bin) diff --git a/tests/cli-rustup.rs b/tests/cli-rustup.rs index 05f2e5690f..a4f5f7bd7b 100644 --- a/tests/cli-rustup.rs +++ b/tests/cli-rustup.rs @@ -512,8 +512,14 @@ fn show_toolchain_override_not_installed() { expect_ok(config, &["rustup", "toolchain", "remove", "nightly"]); // I'm not sure this should really be erroring when the toolchain // is not installed; just capturing the behavior. - expect_err(config, &["rustup", "show"], - for_host!(r"error: toolchain 'nightly-{0}' is not installed")); + let mut cmd = clitools::cmd(config, "rustup", &["show"]); + clitools::env(config, &mut cmd); + let out = cmd.output().unwrap(); + assert!(!out.status.success()); + let stderr = String::from_utf8(out.stderr).unwrap(); + assert!(stderr.starts_with( + for_host!("error: override toolchain 'nightly-{0}' is not installed"))); + assert!(!stderr.contains("info: caused by: not a directory: ")); }); }