Suggest another toolchain when removing a component unavailable to the current toolchain
Similar to the case in #4164:
rustup updatefails (unrelated to issue)rustup target remove wasm32-wasifailsrustup +target remove wasm32-wasisucceeds, 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):
https://github.com/rust-lang/rustup/blob/2919b80da905d44cc731c01add014c2eb3648aed/src/errors.rs#L141-L145
... 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
- The
rustup component rmcase: https://github.com/rust-lang/rustup/pull/5130
i think it can be solved by intercepting the error in the removal execution path and catch the RustupError::UnknownComponents variant.
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.
@devtechedge Please do! For separate concerns, it is recommended to do this in separate PRs.
@rami3l Following #5130 could we also suggest other toolchains for rustup component add by checking locally cached manifests?
@14elias Sure, if you wanna take it please do!
@rustbot claim