Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default for RUSTUP_WINDOWS_PATH_ADD_BIN #3703

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading