diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-09-28 18:13:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-28 18:13:13 +0200 |
| commit | 4eb6b8f43f37b612db58b9cd1682ee7256fb0c43 (patch) | |
| tree | bdb6283fd179b4089350659b0ac18ee6d872006d /src | |
| parent | aa6bd559488a3ad7b6eeff1eb4c75a6e2c6e2632 (diff) | |
| parent | 5e9cab39213b892fdb5eb24d2d27f1ab0918ce46 (diff) | |
| download | rust-4eb6b8f43f37b612db58b9cd1682ee7256fb0c43.tar.gz rust-4eb6b8f43f37b612db58b9cd1682ee7256fb0c43.zip | |
Rollup merge of #147120 - Shunpoco:issue-147105, r=Kobzol
Fix --extra-checks=spellcheck to prevent cargo install every time Fixes rust-lang/rust#147105 ## Background Current implementation of `ensure_version_of_cargo_install` uses `bin_name` to check if it exists, but it should use `<tool_root_dir>/<tool_bin_dir>/<bin_name>` instead. Otherwise the check fails every time, hence the function falls back to install the binary. ## Change Move lines which define bin_path at the top of the function, and use bin_path for the check
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/tidy/src/lib.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 0bfee93796b..874a758bd9b 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -167,12 +167,16 @@ pub fn ensure_version_or_cargo_install( bin_name: &str, version: &str, ) -> io::Result<PathBuf> { + let tool_root_dir = build_dir.join("misc-tools"); + let tool_bin_dir = tool_root_dir.join("bin"); + let bin_path = tool_bin_dir.join(bin_name).with_extension(env::consts::EXE_EXTENSION); + // ignore the process exit code here and instead just let the version number check fail. // we also importantly don't return if the program wasn't installed, // instead we want to continue to the fallback. 'ck: { // FIXME: rewrite as if-let chain once this crate is 2024 edition. - let Ok(output) = Command::new(bin_name).arg("--version").output() else { + let Ok(output) = Command::new(&bin_path).arg("--version").output() else { break 'ck; }; let Ok(s) = str::from_utf8(&output.stdout) else { @@ -182,12 +186,10 @@ pub fn ensure_version_or_cargo_install( break 'ck; }; if v == version { - return Ok(PathBuf::from(bin_name)); + return Ok(bin_path); } } - let tool_root_dir = build_dir.join("misc-tools"); - let tool_bin_dir = tool_root_dir.join("bin"); eprintln!("building external tool {bin_name} from package {pkg_name}@{version}"); // use --force to ensure that if the required version is bumped, we update it. // use --target-dir to ensure we have a build cache so repeated invocations aren't slow. @@ -213,7 +215,6 @@ pub fn ensure_version_or_cargo_install( if !cargo_exit_code.success() { return Err(io::Error::other("cargo install failed")); } - let bin_path = tool_bin_dir.join(bin_name).with_extension(env::consts::EXE_EXTENSION); assert!( matches!(bin_path.try_exists(), Ok(true)), "cargo install did not produce the expected binary" |
