Skip to content

Commit f72c018

Browse files
committed
Panic when nvcc can't be found by which
std::process::Command.output() doesn't return error on non-zero exit, only when command.inner() fails. If `which nvcc` can't find `nvcc` it returns like (ExitStatus(-1), "", "") and causes a panic in the return of the function. Instead, panic on non-zero return with an informational diagnostic message.
1 parent 63abe77 commit f72c018

File tree

1 file changed

+6
-3
lines changed
  • crates/find_cuda_helper/src

1 file changed

+6
-3
lines changed

crates/find_cuda_helper/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,13 @@ fn detect_cuda_root_via_which_nvcc() -> PathBuf {
157157
let output = Command::new("which")
158158
.arg("nvcc")
159159
.output()
160-
.expect("Command `which` must be available on *nix like systems.")
161-
.stdout;
160+
.expect("Command `which` must be available on *nix like systems.");
162161

163-
let path: PathBuf = String::from_utf8(output)
162+
if !output.status.success() {
163+
panic!("Couldn't find nvcc - `which nvcc` returned non-zero");
164+
}
165+
166+
let path: PathBuf = String::from_utf8(output.stdout)
164167
.expect("Result must be valid UTF-8")
165168
.trim()
166169
.to_string()

0 commit comments

Comments
 (0)