Skip to content

Commit

Permalink
Stop defaulting to $PATH searches when the binary can't be found and …
Browse files Browse the repository at this point in the history
…causing infinite recursion
  • Loading branch information
Manishearth committed Jan 9, 2017
1 parent 4381291 commit dfda79f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/rustup/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`")
}
Expand Down
12 changes: 6 additions & 6 deletions src/rustup/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit dfda79f

Please sign in to comment.