diff --git a/src/rustup/errors.rs b/src/rustup/errors.rs index 361677c687a..6970676ef1b 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) } + BinaryNotFound(t: String, bin: String) { + description("toolchain does not contain binary") + display("toolchain '{}' does not have the binary `{}`", t, bin) + } NeedMetadataUpgrade { description("rustup's metadata is out of date. run `rustup self upgrade-data`") } diff --git a/src/rustup/toolchain.rs b/src/rustup/toolchain.rs index d0d47de9f8c..a68f126a0ea 100644 --- a/src/rustup/toolchain.rs +++ b/src/rustup/toolchain.rs @@ -301,13 +301,13 @@ impl<'a> Toolchain<'a> { }; let bin_path = self.path.join("bin").join(&binary); - let mut cmd = Command::new(if utils::is_file(&bin_path) { - &bin_path + let mut cmd = if utils::is_file(&bin_path) { + Command::new(&bin_path) } else { - // If the bin doesn't actually exist in the sysroot, let the OS try - // to resolve it globally for us - Path::new(&binary) - }); + return Err(ErrorKind::BinaryNotFound(self.name.clone(), + binary.to_string_lossy().into()) + .into()) + }; self.set_env(&mut cmd); Ok(cmd) }