Skip to content

Commit

Permalink
Merge pull request #100 from epage/win
Browse files Browse the repository at this point in the history
fix: Make work on Windows
  • Loading branch information
epage authored Sep 1, 2022
2 parents c994518 + cdf5e45 commit 7fcf77b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,17 +1077,27 @@ fn cargo(
script_args: &[OsString],
run_quietly: bool,
) -> MainResult<Command> {
let mut cmd = Command::new("cargo");
// Always specify a toolchain to avoid being affected by rust-version(.toml) files:
let toolchain_version = toolchain_version.unwrap_or("stable");

let mut cmd = if std::env::var_os("RUSTUP_TOOLCHAIN").is_some() {
// Running inside rustup which can't always call into rustup proxies, so explicitly call
// rustup
let mut cmd = Command::new("rustup");
cmd.args(["run", toolchain_version, "cargo"]);
cmd
} else {
let mut cmd = Command::new("cargo");
cmd.arg(format!("+{}", toolchain_version));
cmd
};

// Set tracing on if not set
if std::env::var_os("RUST_BACKTRACE").is_none() {
cmd.env("RUST_BACKTRACE", "1");
info!("setting RUST_BACKTRACE=1 for this cargo run");
}

// Always specify a toolchain to avoid being affected by rust-version(.toml) files:
cmd.arg(format!("+{}", toolchain_version.unwrap_or("stable")));

cmd.arg(cmd_name);

if cmd_name == "run" && run_quietly {
Expand Down

0 comments on commit 7fcf77b

Please sign in to comment.