Skip to content

feat(config)!: use unqualified names for default_toolchain - #4947

Open
rami3l wants to merge 5 commits into
rust-lang:mainfrom
rami3l:feat/unqualified-default-toolchain
Open

feat(config)!: use unqualified names for default_toolchain#4947
rami3l wants to merge 5 commits into
rust-lang:mainfrom
rami3l:feat/unqualified-default-toolchain

Conversation

@rami3l

@rami3l rami3l commented Jul 9, 2026

Copy link
Copy Markdown
Member

Stacked on #4950 and #4991, closes #4945.

Problem Description

The original problem as seen in both #3651 and #4945 is the following:

For now, rustup default <toolchain> resolves the full toolchain name from <toolchain>, which could be a function of default_host_tuple, and then stores that in settings.toml.
#4945

... this is notably problematic because the value of default_toolchain is inappropriately coupled with the value of the default host at the wrong moment: not the moment of running any rustup command, but the last execution of rustup default (whether manually by running that very command, or implicitly upon rustup-init):

This has made the config file hostile to cross-platform dotfile management, since one may want to use the stable toolchain specific to the default host tuple of that platform.
#4945 (comment)

i have a stable-x86_64-pc-windows-gnu toolchain as my default [..] i want it to be -msvc instead so i can use windbg (i don't have gdb installed). i ran rustup set default-host x86_64-pc-windows-msvc, which succeeded, but did not install any toolchains or change the default:
#3651 (comment)

Proposed Solution

This PR makes rustup use unqualified names such as stable instead of fully qualified names such as stable-aarch64-apple-darwin for the default_toolchain field in the settings.toml file.

Impact

Compatibility

This change is breaking exactly because the determination of the default toolchain will change to reflect the change of the default host tuple.

However, the user can always get the old behavior by specifying the fully qualified name when running rustup default (such as rustup default stable-aarch64-apple-darwin), in the rare case that they would like to decouple the default toolchain from the default host tuple.

For users with an existing settings.toml, manually running rustup default stable or similar commands should be necessary for them to get the new behavior.

Performance

As discussed in #4945 (comment), since the default host tuple is resolved at the beginning of rustup's execution, this change has introduced no extra I/O operations, and thus the performance impact is negligible.

Validation

Validated through both local testing, a specific test case that reflects @jyn514's original use case as described in #3651, as well as another specific test case that explicitly asserts backwards compatibility with existing settings.toml format with a fully qualified default_toolchain name.

@rami3l rami3l changed the title refactor(config): extract Cfg::get_default_resolvable() feat(config)!: use unqualified names for default_toolchain Jul 9, 2026
Comment thread src/cli/self_update.rs Outdated
Comment thread src/cli/self_update.rs Outdated
@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch 2 times, most recently from 1d2c5c6 to 108ca96 Compare July 14, 2026 19:51
@rustbot

This comment has been minimized.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch 5 times, most recently from 37bfef2 to 8975942 Compare July 23, 2026 09:14
@rustbot

This comment has been minimized.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from 8975942 to bb5bf44 Compare July 23, 2026 10:51
Comment thread src/cli/self_update.rs
Comment thread src/cli/self_update.rs
@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from bb5bf44 to 9f1d12c Compare July 25, 2026 08:14
@rami3l
rami3l marked this pull request as ready for review July 27, 2026 08:33
@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from 9f1d12c to 5616ba4 Compare July 27, 2026 08:33
@rustbot

This comment has been minimized.

@rami3l
rami3l requested a review from djc July 27, 2026 08:37
Comment thread src/config.rs Outdated
Comment thread src/toolchain/names.rs Outdated
Comment thread src/cli/self_update.rs
@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from 5616ba4 to 34ad35f Compare August 3, 2026 07:59
@rustbot

This comment has been minimized.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch 2 times, most recently from aa51f83 to 04c0cc9 Compare August 3, 2026 08:24
@rami3l
rami3l requested a review from djc August 3, 2026 08:24
@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from 04c0cc9 to 52d7cb1 Compare August 3, 2026 09:09
@rustbot

This comment has been minimized.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from 52d7cb1 to e737b5f Compare August 3, 2026 12:51
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from e737b5f to afe6341 Compare August 10, 2026 14:47
@rustbot

This comment has been minimized.

@rami3l

rami3l commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

@djc Would you mind giving this PR another look please? 🙇

@rustbot

This comment has been minimized.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from afe6341 to b2b31f2 Compare August 11, 2026 07:47
@rustbot

This comment has been minimized.

@djc

djc commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Stacked on #4950 and #4991, closes #4945.

The breakage should be minimal anyway because the default host tuple almost never changes.

I think the PR description should explain (a) what you're trying to achieve here and (b) how you're trying to achieve it, and probably (c) the effects on backwards compatibility, instead of just relying on issue/PR references.

@rami3l
rami3l marked this pull request as draft August 11, 2026 11:35
@rami3l
rami3l marked this pull request as ready for review August 11, 2026 15:51
@rami3l

rami3l commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

I think the PR description should explain (a) what you're trying to achieve here and (b) how you're trying to achieve it, and probably (c) the effects on backwards compatibility, instead of just relying on issue/PR references.

@djc Thank you so much for this suggestion! I have completely rewritten the PR description to include the 3 points mentioned above. Please don't hesitate to tell me if you happen to have any more concerns, as I will try my best to address them.

@djc

djc commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This change is breaking exactly because the determination of the default toolchain will change to reflect the change of the default host tuple.

However, the user can always get the old behavior by specifying the fully qualified name when running rustup default (such as rustup default stable-aarch64-apple-darwin), in the rare case that they would like to decouple the default toolchain from the default host tuple.

For users with an existing settings.toml, manually running rustup default stable or similar commands should be necessary for them to get the new behavior.

In the code, it was not clear to me how/where old configurations with fully qualified names where still kept supported. I think it would be good to add some comments that make it obvious where/how that happens and that it must not regress.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from b2b31f2 to e12fcfc Compare August 11, 2026 16:42
@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from e12fcfc to f8de503 Compare August 11, 2026 16:47
@rami3l

rami3l commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

In the code, it was not clear to me how/where old configurations with fully qualified names where still kept supported. I think it would be good to add some comments that make it obvious where/how that happens and that it must not regress.

@djc Sure! I have just added one regression test specifically for the case you've mentioned, asserting that settings.toml can contain a fully qualified toolchain name which can be generated by rustup default followed by that name, both before and after this breaking change.

In addition, I've added two more assertions against the exact shape of settings.toml in the originally introduced test case.

@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from f8de503 to 5207d09 Compare August 11, 2026 16:53
@rami3l
rami3l force-pushed the feat/unqualified-default-toolchain branch from 5207d09 to b24bd2b Compare August 11, 2026 16:57
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.

Should default_toolchain in settings.toml allow unresolved names?

3 participants