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

Append Windows "bin" directory to PATH #4249

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

ChrisDenton
Copy link
Member

Hopefully fixes #3825

On Windows rustc's "bin" directory is now appended to the end of PATH so that:

  • All DLLs within "bin" can be found by the loader but
  • The EXEs within "bin" will not override anything else on PATH

I can't think of a downside to doing this but I'm happy to be corrected. As with prepending paths, it won't add to PATH if that already contains the path. This also means that the behaviour of RUSTUP_WINDOWS_PATH_ADD_BIN=1 is currently unchanged.

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if the env var is enabled this adds two path entries, is that desirable? Maybe we can ignore the env var after this change?

@djc
Copy link
Contributor

djc commented Mar 12, 2025

LGTM but I defer judgement to people who better understand Windows stuff.

Maybe r? @wesleywiser?

@ChrisDenton
Copy link
Member Author

i think if the env var is enabled this adds two path entries, is that desirable? Maybe we can ignore the env var after this change?

The deduplication logic should stop the path being added twice. But I have no objection to removing the env var.

@ChrisDenton
Copy link
Member Author

The PATH behaviour can now be fully controlled using the RUSTUP_WINDOWS_PATH_ADD_BIN environment variable:

  • RUSTUP_WINDOWS_PATH_ADD_BIN=0 is the 1.27 behaviour of not adding the bin directory to PATH
  • RUSTUP_WINDOWS_PATH_ADD_BIN=1 is the older behaviour of prepending the bin directory to PATH
  • Unset or anything else appends the bin directory to PATH

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM! I think the current commit history doesn't totally makes sense, maybe just squash the changes so there's only one commit?

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me but I agree that making this new behavior controlled by RUSTUP_WINDOWS_PATH_ADD_BIN=2 and that the default would be more cautious.

This also allows opting out of the new default using the `RUSTUP_WINDOWS_PATH_ADD_BIN`. Setting it controls if or where the bin directory is added to PATH:

0 => don't add to PATH
1 => prepend to PATH
unset, or anything else => append to PATH
@rami3l rami3l added this pull request to the merge queue Mar 14, 2025
Merged via the queue into rust-lang:master with commit 51a0b39 Mar 14, 2025
29 checks passed
@ChrisDenton ChrisDenton deleted the append_path branch March 14, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Effects of RUSTUP_WINDOWS_PATH_ADD_BIN change
5 participants