Skip to content

Commit

Permalink
Change default for RUSTUP_WINDOWS_PATH_ADD_BIN
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss authored and djc committed Mar 12, 2024
1 parent b15a989 commit ce3c09a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
9 changes: 6 additions & 3 deletions src/toolchain/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'a> Toolchain<'a> {
}

if cfg!(target_os = "windows") {
// Historically rustup has included the bin directory in PATH to
// Historically rustup included the bin directory in PATH to
// work around some bugs (see
// https://github.com/rust-lang/rustup/pull/3178 for more
// information). This shouldn't be needed anymore, and it causes
Expand All @@ -174,10 +174,13 @@ impl<'a> Toolchain<'a> {
// recursive call won't work because it is not executing the
// proxy, so the `+` toolchain override doesn't work.
//
// This is opt-in to allow us to get more real-world testing.
// The RUSTUP_WINDOWS_PATH_ADD_BIN env var was added to opt-in to
// testing the fix. The default is now off, but this is left here
// just in case there are problems. Consider removing in the
// future if it doesn't seem necessary.
if process()
.var_os("RUSTUP_WINDOWS_PATH_ADD_BIN")
.map_or(true, |s| s == "1")
.map_or(false, |s| s == "1")
{
path_entries.push(self.path.join("bin"));
}
Expand Down
16 changes: 1 addition & 15 deletions tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,21 +586,7 @@ fn recursive_cargo() {
fs::create_dir_all(&cargo_bin_path).unwrap();
fs::copy(real_mock_cargo, cargo_subcommand).unwrap();

// Verify the default behavior, which is currently broken on Windows.
let args = &["cargo", "--recursive-cargo-subcommand"];
if cfg!(windows) {
config.expect_err(
&["cargo", "--recursive-cargo-subcommand"],
"bad mock proxy commandline",
);
}

// Try the opt-in, which should fix it.
let out = config.run(args[0], &args[1..], &[("RUSTUP_WINDOWS_PATH_ADD_BIN", "0")]);
if !out.ok || !out.stdout.contains("hash-nightly-2") {
clitools::print_command(args, &out);
panic!("expected hash-nightly-2 in output");
}
config.expect_stdout_ok(&["cargo", "--recursive-cargo-subcommand"], "hash-nightly-2");
});
});
}
Expand Down

0 comments on commit ce3c09a

Please sign in to comment.