Skip to content

Improve error message for rustup target add invalid-target #3318

Closed

Description

@jyn514

Problem you are trying to solve

Consider this error:

; rustup target add wasm
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not contain component 'rust-std' for target 'wasm'
note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html
help: consider using `cargo build -Z build-std` instead

The pointer to platform-support.html is good and helpful, but the rest of these messages are a bit misleading. The problem is that wasm isn't a target, I need to pick a specific version of wasm:

; rustc --print=target-list | grep wasm
wasm32-unknown-emscripten
wasm32-unknown-unknown
wasm32-wasi
wasm64-unknown-unknown

Solution you'd like

Have rustup check the output of rustc --print=target-list for the specified toolchain and give a more helpful error if it doesn't have the target. Maybe something like this:

; rustup target add wasm
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 'wasm'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html

Notes

No response

Activity

  1. self-assigned this
    on May 7, 2023
  2. 0xPoe commented on May 7, 2023

    @0xPoe
    Member

    I will try to improve it.

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