Skip to content

Suggest another toolchain when removing a component unavailable to the current toolchain #5098

Open

Description

@rami3l

Similar to the case in #4164:

  1. rustup update fails (unrelated to issue)
    Image
  2. rustup target remove wasm32-wasi fails
    Image
  3. rustup +target remove wasm32-wasi succeeds, as the default toolchain was nightly as specified in .rustup/settings.toml

... however the related error kind is RustupError::UnknownComponents which would be emitted during both rustup component add and rustup component rm (instead of the rustup target rm command shown above):

rustup/src/errors.rs

Lines 141 to 145 in 2919b80

#[error("{}", unknown_components_msg(.desc, .components))]
UnknownComponents {
desc: ToolchainDesc,
components: Vec<UnknownComponentInfo>,
},

... so we should be smarter in terms of suggestions. Or, as a simplification, if suggesting rustup component add turns out to be non trivial, we can do the rustup component rm case first.

Tasks

Activity

  1. 14elias commented on Sep 23, 2026

    @14elias
    Contributor

    i think it can be solved by intercepting the error in the removal execution path and catch the RustupError::UnknownComponents variant.

  2. devtechedge commented on Oct 6, 2026

    @devtechedge
    Contributor

    I'd like to take the component rm case, following the same approach #5094 used for targets.

    While testing, I noticed that removing rust-src on a toolchain that doesn't have it panics with "component target should be known".

    I can fix that as a separate commit in the same PR, or open it as its own PR if you'd prefer.

  3. rami3l commented on Oct 6, 2026

    @rami3l
    MemberAuthor

    @devtechedge Please do! For separate concerns, it is recommended to do this in separate PRs.

  4. 14elias commented on Oct 10, 2026

    @14elias
    Contributor

    @rami3l Following #5130 could we also suggest other toolchains for rustup component add by checking locally cached manifests?

  5. rami3l commented on Oct 10, 2026

    @rami3l
    MemberAuthor

    @14elias Sure, if you wanna take it please do!

  6. 14elias commented on Oct 10, 2026

    @14elias
    Contributor

    @rustbot claim

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions