Skip to content

Commit 3290d1a

Browse files
committed
ensure_version_or_cargo_install: reinstate version check
1 parent 27dcfe1 commit 3290d1a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/build_helper/src/util.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ pub fn ensure_version_or_cargo_install(
7676
bin_name: &str,
7777
version: &str,
7878
) -> io::Result<PathBuf> {
79+
// ignore the process exit code here and instead just let the version number check fail.
80+
// we also importantly don't return if the program wasn't installed,
81+
// instead we want to continue to the fallback.
82+
'ck: {
83+
// FIXME: rewrite as if-let chain once this crate is 2024 edition.
84+
let Ok(output) = Command::new(bin_name).arg("--version").output() else {
85+
break 'ck;
86+
};
87+
let Ok(s) = str::from_utf8(&output.stdout) else {
88+
break 'ck;
89+
};
90+
let Some(v) = s.trim().split_whitespace().last() else {
91+
break 'ck;
92+
};
93+
if v == version {
94+
return Ok(PathBuf::from(bin_name));
95+
}
96+
}
97+
7998
let tool_root_dir = build_dir.join("misc-tools");
8099
let tool_bin_dir = tool_root_dir.join("bin");
81100
// use --force to ensure that if the required version is bumped, we update it.

0 commit comments

Comments
 (0)