rustup: `rustup default` no longer exits with `1` with no default toolchain is set

Verification

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.

Steps

  1. rustup default none
  2. rustup 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)

Most upvoted comments

Hm, rustup show does return an exit code of 1 on 1.27.1 but not on 1.28.

rustup default has 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 😃

What does your $RUSTUP_HOME/settings.toml show as the default toolchain?

With rustup default none it doesn’t have any default toolchain set:

profile = "default"
version = "12"

[overrides]

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:

> rustup default none
info: default toolchain unset
> rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
> rustup show; echo $LastExitCode
Default host: x86_64-pc-windows-msvc
rustup home:  F:\Programs\rust-lang\Rustup

installed toolchains
--------------------

error: no default toolchain configured
1

I can definitely sympathize with being new! Do we need to add this as a release blocker somewhere?

@ChrisDenton Added to https://github.com/rust-lang/rustup/issues/3998#issuecomment-2516233499.