Skip to content

Commit cdf5e45

Browse files
committed
fix: Make work on Windows
This works around rust-lang/rustup#3036
1 parent c994518 commit cdf5e45

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/main.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,17 +1077,27 @@ fn cargo(
10771077
script_args: &[OsString],
10781078
run_quietly: bool,
10791079
) -> MainResult<Command> {
1080-
let mut cmd = Command::new("cargo");
1080+
// Always specify a toolchain to avoid being affected by rust-version(.toml) files:
1081+
let toolchain_version = toolchain_version.unwrap_or("stable");
1082+
1083+
let mut cmd = if std::env::var_os("RUSTUP_TOOLCHAIN").is_some() {
1084+
// Running inside rustup which can't always call into rustup proxies, so explicitly call
1085+
// rustup
1086+
let mut cmd = Command::new("rustup");
1087+
cmd.args(["run", toolchain_version, "cargo"]);
1088+
cmd
1089+
} else {
1090+
let mut cmd = Command::new("cargo");
1091+
cmd.arg(format!("+{}", toolchain_version));
1092+
cmd
1093+
};
10811094

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

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

10931103
if cmd_name == "run" && run_quietly {

0 commit comments

Comments
 (0)