rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.17k stars 889 forks source link

The `error reading rustc version` message could be improved #3607

Open rustrust opened 10 months ago

rustrust commented 10 months ago

Problem

M1 macOS 12.4.1

> rustup update
info: syncing channel updates for 'stable-aarch64-apple-darwin'
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'nightly-aarch64-apple-darwin'
info: checking for self-update

      stable-aarch64-apple-darwin unchanged - rustc 1.75.0 (82e1608df 2023-12-21)
  stable-x86_64-unknown-linux-gnu unchanged - (error reading rustc version)
     nightly-aarch64-apple-darwin unchanged - rustc 1.77.0-nightly (89e2160c4 2023-12-27)

Steps

rustup update with stable-x86_64-unknown-linux-gnu toolchain

Possible Solution(s)

No response

Notes

No response

Rustup version

rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.75.0 (82e1608df 2023-12-21)`

### Installed toolchains

```console
Default host: aarch64-apple-darwin
rustup home:  /Users/foobar/.rustup

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

stable-aarch64-apple-darwin (default)
stable-x86_64-unknown-linux-gnu
nightly-aarch64-apple-darwin
1.60.0-aarch64-apple-darwin
1.61.0-aarch64-apple-darwin
1.65.0-aarch64-apple-darwin
1.70.0-aarch64-apple-darwin

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
aarch64-unknown-linux-gnu
x86_64-pc-windows-msvc

active toolchain
----------------

stable-aarch64-apple-darwin (default)
rustc 1.75.0 (82e1608df 2023-12-21)
rami3l commented 10 months ago

@rustrust Thanks for filing this issue!

It seems that you're using Rust on macOS, so stable-x86_64-unknown-linux-gnu can't normally be a running host triple. The error reading rustc version error indicates exactly that: rustup tries to run rustc to find out the exact version, but you cannot run x64 Linux binaries on ARM64 macOS.

Maybe you're setting up cross compilation? In that case, you should add a new target triple under your aarch64-apple-darwin toolchain, like you did with aarch64-unknown-linux-gnu.

Please feel free to tell me if have further concerns. Have a nice day!

rustrust commented 10 months ago

To prevent others from being perplexed by this in the future, maybe a different error message (one not using the word "error") might be helpful here?

rami3l commented 10 months ago

@rustrust This error only indicates that rustup failed to invoke rustc, and no further info can be provided.

IRL this can happen for multiple reasons, e.g. the permission is not correct, the binary is corrupted, etc.

Although accidentally installing the binary built for another platform is indeed another possible reason, this particular situation should be quite rare IMHO.

Do you happen to have any specific error message in mind?

djc commented 10 months ago

IRL this can happen for multiple reasons, e.g. the permission is not correct, the binary is corrupted, etc.

It would probably be helpful if we can propagate/show the exact error condition that triggered this.

rami3l commented 7 months ago

Reopening since it's still valuable to enhance the error message.