Skip to content

v1.28.0 broke rustup show active-toolchain #4217

Description

@Sky9x

Problem

IntelliJ RustRover and scripts use rustup show active-toolchain to get the active toolchain name. The output is now broken as it includes a message "active because: it's the default toolchain" on a second line.
This happened in #3225.

$ rustup show active-toolchain --help
Show the active toolchain

Usage: rustup[EXE] show active-toolchain [OPTIONS]

Options:
  -v, --verbose  Enable verbose output with rustc information
  -h, --help     Print help

Discussion:
    Shows the name of the active toolchain.

    This is useful for figuring out the active tool chain from
    scripts.

    You should use `rustc --print sysroot` to get the sysroot, or
    `rustc --version` to get the toolchain version.

This is useful for figuring out the active tool chain from scripts.

Which is why it should output exactly the toolchain name, nothing more.

Steps

Current output (v1.28.0):

$ rustup show active-toolchain
nightly-x86_64-unknown-linux-gnu
active because: it's the default toolchain

Gives this chaotic error when loading any project in RustRover:

Execution failed (exit code 1).
/home/sky9/.cargo/bin/cargo "+nightly-x86_64-unknown-linux-gnu
active because: it's the default toolchain" vendor --respect-source-config /home/sky9/.cache/JetBrains/RustRover2025.1/intellij-rust/stdlib/1.87.0-nightly-c16751b793dfce34909c1ba3fd1cbf4f827d7deb/vendor
    in working directory: /home/sky9/.cache/JetBrains/RustRover2025.1/intellij-rust/stdlib-local-copy/1.87.0-nightly-9375198e512f5c5ff5ae71857b1e38933ec1941d/library/sysroot
    with extra environment variables: RUSTC_BOOTSTRAP=1 TERM=ansi RUST_BACKTRACE=short RUSTC=/home/sky9/.cargo/bin/rustc
stdout: error: toolchain 'nightly-x86_64-unknown-linux-gnu
active because: it's the default toolchain' is not installed

stderr: 

It is trying to find a toolchain with the name nightly-x86_64-unknown-linux-gnu\nactive because: it's the default toolchain (with a newline in the middle) which obviously doesn't exist.

Previous output (v1.27.1 and below):

$ rustup show active-toolchain
nightly-x86_64-unknown-linux-gnu (default)

Possible Solution(s)

A v1.28.1 should be released with a patch reverting just the rustup show active-toolchain output back to pre-1.28.0 behavior.

Rustup version

rustup 1.28.0 (6e19fbec7 2025-03-02)

cc @majaha @rami3l @rust-lang/rustup

Activity

  1. Dchll commented on Mar 4, 2025

    @Dchll

    I also came across

  2. majaha commented on Mar 4, 2025

    @majaha
    Contributor

    Just for clarity: the previous output of rustup show active-toolchain was:

    stable-x86_64-pc-windows-msvc (default)
    

    Note the brackets at the end. So something like cargo +$(rustup show active-toolchain) foo wouldn't have worked (and this specific instance isn't useful, as it sets the active toolchain to the active toolchain.)

    The intention was to make it easier to parse in scripts, because you can split on the newline to get the toolchain name, while also making the reason-for-active much more intuitive.

    I'm not sure what Rust Rover was doing, but breaking it probably isn't good. Perhaps they were cutting out the brackets directly.

  3. RalfJung commented on Mar 5, 2025

    @RalfJung
    Member

    FWIW this change also broke some logic in miri-test-libstd (that I already fixed by now), where it was using this rune to get the toolchain name:

    rustup show active-toolchain | cut -f 1 -d' '
    

    I have now changed this to

    rustup show active-toolchain | head -n1 | cut -f 1 -d' '
    

    The newline indeed makes it easier to parse, but unfortunately throws off existing parsers... so yeah the revert is probably a good idea. Would be nice to clean this up eventually, but that seems non-trivial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions