Skip to content

Commit 841448b

Browse files
committed
ensure_version_or_cargo_install: don't hardcode path to cargo
1 parent 1a288a8 commit 841448b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/build_helper/src/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub fn parse_gitmodules(target_dir: &Path) -> Vec<String> {
7272
/// otherwise install via cargo.
7373
pub fn ensure_version_or_cargo_install(
7474
build_dir: &Path,
75+
cargo: &Path,
7576
pkg_name: &str,
7677
bin_name: &str,
7778
version: &str,
@@ -101,7 +102,7 @@ pub fn ensure_version_or_cargo_install(
101102
// use --force to ensure that if the required version is bumped, we update it.
102103
// use --target-dir to ensure we have a build cache so repeated invocations aren't slow.
103104
// modify PATH so that cargo doesn't print a warning telling the user to modify the path.
104-
let cargo_exit_code = Command::new("cargo")
105+
let cargo_exit_code = Command::new(cargo)
105106
.args(["install", "--locked", "--force", "--quiet"])
106107
.arg("--root")
107108
.arg(&tool_root_dir)

src/tools/tidy/src/extra_checks/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub fn check(
5353
librustdoc_path: &Path,
5454
tools_path: &Path,
5555
npm: &Path,
56+
cargo: &Path,
5657
bless: bool,
5758
extra_checks: Option<&str>,
5859
pos_args: &[String],
@@ -65,6 +66,7 @@ pub fn check(
6566
librustdoc_path,
6667
tools_path,
6768
npm,
69+
cargo,
6870
bless,
6971
extra_checks,
7072
pos_args,
@@ -80,6 +82,7 @@ fn check_impl(
8082
librustdoc_path: &Path,
8183
tools_path: &Path,
8284
npm: &Path,
85+
cargo: &Path,
8386
bless: bool,
8487
extra_checks: Option<&str>,
8588
pos_args: &[String],
@@ -295,7 +298,7 @@ fn check_impl(
295298
} else {
296299
eprintln!("spellcheck files");
297300
}
298-
spellcheck_runner(&outdir, &args)?;
301+
spellcheck_runner(&outdir, &cargo, &args)?;
299302
}
300303

301304
if js_lint || js_typecheck {
@@ -579,8 +582,8 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> {
579582
}
580583

581584
/// Check that spellchecker is installed then run it at the given path
582-
fn spellcheck_runner(outdir: &Path, args: &[&str]) -> Result<(), Error> {
583-
let bin_path = ensure_version_or_cargo_install(outdir, "typos-cli", "typos", "1.34.0")?;
585+
fn spellcheck_runner(outdir: &Path, cargo: &Path, args: &[&str]) -> Result<(), Error> {
586+
let bin_path = ensure_version_or_cargo_install(outdir, cargo, "typos-cli", "typos", "1.34.0")?;
584587

585588
match Command::new(bin_path).args(args).status() {
586589
Ok(status) => {

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ fn main() {
184184
&librustdoc_path,
185185
&tools_path,
186186
&npm,
187+
&cargo,
187188
bless,
188189
extra_checks,
189190
pos_args

0 commit comments

Comments
 (0)