rustup: `rustup default` no longer exits with `1` with no default toolchain is set
Verification
- I searched for recent similar issues at https://github.com/rust-lang/rustup/issues?q=is%3Aissue+is%3Aopen%2Cclosed and found no duplicates.
- I am on the latest version of Rustup according to https://github.com/rust-lang/rustup/tags and am still able to reproduce my issue.
Problem
(Edited by @rami3l to better reflect the original issue)
Coming from https://internals.rust-lang.org/t/seeking-beta-testers-for-rustup-v1-28-0/22060.
With rustup v1.27.1, the following shell snippet can be used to force the installation of the default toolchain, or fall back on stable when none is present:
rustup default || rustup default stable
When testing out the upcoming 1.28 release, however, I found that rustup default is returning 0 even there’s no such thing as the default toolchain, resulting in an unchanged default toolchain state.
I’ve noticed the suggestion provided in the post:
rustup show active-toolchain || rustup toolchain install
… but it doesn’t really help with the use case above, since regardless in 1.27.1, the current stable branch (1.28-beta), it seems to always exit with code 0.
1.27.1https://github.com/rust-lang/rustup/blob/54dd3d00fd20e64dc522517a0d7be4285570a2f1/src/cli/rustup_mode.rs#L1227-L1257stablehttps://github.com/rust-lang/rustup/blob/7ccf717e6e1aee46f65cc6fea4132a3f0e37593b/src/cli/rustup_mode.rs?plain=1#L1100-L1105
Steps
rustup default nonerustup default || rustup default stable
Possible Solution(s)
Should we find another workaround?
Notes
No response
Rustup version
* rustup 1.27.1 (1980-01-01)
* rustup 1.28.0 (7ccf717e6e1aee46f65cc6fea4132a3f0e37593b)
Installed toolchains
rustup 1.27.1
installed toolchains
--------------------
error: no default toolchain configured
rustup 1.28.0
installed toolchains
--------------------
active toolchain
----------------
no active toolchain
OS version
Both Darwin and Linux
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 20 (20 by maintainers)
rustup defaulthas changed its exit code as well when no default.Should we have a small “compatibility notes” section for these changes in our changelog, just like how rust release does?
Anyway, thanks people for your help! For my own usage, I can definitely find workarounds. I am good with any approach we take, or doing nothing 😃
With
rustup default noneit doesn’t have any default toolchain set:Weirdly I couldn’t reproduce the issue when running in Windows sandbox but it does reproduce on two of my machines. Maybe it’s something to do with my non-standard setup. 1.28 is fine though so I’m not sure if it’s particularly worth investigating if it was just a bug in 1.27.1?
I’m not aware of any but then I wasn’t aware of this difference.
I’m not sure even why it’s different, which worries me. Shouldn’t our tests detect this?
Hm, in powershell on Windows 11:
@ChrisDenton Added to https://github.com/rust-lang/rustup/issues/3998#issuecomment-2516233499.