Skip to content

Commit 2968c39

Browse files
committed
ensure rustc managed to print the sysroot
1 parent a341089 commit 2968c39

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

collector/src/toolchain.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,15 @@ pub fn create_toolchain_from_published_version(
589589
}
590590

591591
fn get_lib_dir_from_rustc(rustc: &Path) -> anyhow::Result<PathBuf> {
592-
let sysroot = Command::new(rustc)
593-
.arg("--print")
594-
.arg("sysroot")
595-
.output()?
596-
.stdout;
597-
let sysroot_path = String::from_utf8_lossy(&sysroot);
598-
592+
let output = Command::new(rustc).arg("--print").arg("sysroot").output()?;
593+
if !output.status.success() {
594+
anyhow::bail!(
595+
"rustc failed to provide sysroot, exit status: {}\nstderr: {}",
596+
output.status,
597+
String::from_utf8_lossy(&output.stderr)
598+
);
599+
}
600+
let sysroot_path = String::from_utf8_lossy(&output.stdout);
599601
Ok(Path::new(sysroot_path.as_ref().trim()).join("lib"))
600602
}
601603

0 commit comments

Comments
 (0)