Skip to content

Commit

Permalink
Merge pull request #1549 from mkroening/no-assume-exists
Browse files Browse the repository at this point in the history
fix(xtask): don't assume exe exists in `cargo_home`
  • Loading branch information
mkroening authored Jan 13, 2025
2 parents b2eef95 + c81caf8 commit 12b04c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod clippy;
mod doc;

use std::env;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::Command;

use anyhow::Result;
Expand Down Expand Up @@ -74,7 +74,13 @@ fn sanitize(cmd: &str) -> Command {
let mut cargo_home = home::cargo_home().unwrap();
cargo_home.push("bin");
cargo_home.push(&exe);
cargo_home
if cargo_home.exists() {
cargo_home
} else {
// Custom `$CARGO_HOME` values do not necessarily reflect in the environment.
// For these cases, our best bet is using `$PATH` for resolution.
PathBuf::from(exe)
}
};

let mut cmd = Command::new(cmd);
Expand Down

0 comments on commit 12b04c9

Please sign in to comment.