Skip to content

Commit

Permalink
fix: Make work on Windows
Browse files Browse the repository at this point in the history
This works around rust-lang/rustup#3036
  • Loading branch information
epage committed Sep 1, 2022
1 parent c994518 commit cdf5e45
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 cdf5e45

Please sign in to comment.