You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The error reading rustc version message could be improved #3607
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)`
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 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?
The error message comes from Toolchain::rustc_version. I can see there are several ignored std::io::Errors and one anyhow::Error from Toolchain::create_command. I've tested it in my fork (Bogay@2ceb33c) and here are some output examples of Toolchain::rustc_version by rustup show -v:
(error reading rustc version: Exec format error (os error 8))
@Bogay I think if the attacker cannot write arbitrary output into our error message then we'd be good. Although I know io::Error is open-ended, it seems that Command::spawn() can only throw some of them, so you have a very limited set of output to handle.
Would you mind submitting a PR (even in draft state) so we can have a further look?
it seems that Command::spawn() can only throw some of them, so you have a very limited set of output to handle.
I agree that the error messages can be improved for some common cases. However, I am not sure which errors should be handled. As per discussion in rust-lang/rust#108213, it seems that rust std does not guarantee returned errors of those methods.
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.
Is there a reason why unknown-linux-musl would error on Linux while unknown-linux-gnu succeeds?
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.
Is there a reason why unknown-linux-musl would error on Linux while unknown-linux-gnu succeeds?
Activity
rami3l commentedon Jan 2, 2024
@rustrust Thanks for filing this issue!
It seems that you're using Rust on macOS, so
stable-x86_64-unknown-linux-gnucan't normally be a running host triple.The
error reading rustc versionerror indicates exactly that:rustuptries to runrustcto 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-darwintoolchain, like you did withaarch64-unknown-linux-gnu.Please feel free to tell me if have further concerns.
Have a nice day!
rustrust commentedon Jan 2, 2024
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 commentedon Jan 2, 2024
@rustrust This error only indicates that
rustupfailed to invokerustc, 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 commentedon Jan 2, 2024
It would probably be helpful if we can propagate/show the exact error condition that triggered this.
[-] stable-x86_64-unknown-linux-gnu unchanged - (error reading rustc version)[/-][+]The `error reading rustc version` message could be improved[/+]rami3l commentedon Apr 15, 2024
Reopening since it's still valuable to enhance the error message.
Bogay commentedon Mar 5, 2026
The error message comes from
Toolchain::rustc_version. I can see there are several ignoredstd::io::Errors and oneanyhow::ErrorfromToolchain::create_command. I've tested it in my fork (Bogay@2ceb33c) and here are some output examples ofToolchain::rustc_versionbyrustup show -v:(error reading rustc version: Exec format error (os error 8))(error reading rustc version: exit status: 42)(error reading rustc version: Permission denied (os error 13))Is it acceptable to simply append the captured error to the output format string? I'm concerned that they become too long in some cases.
rustup/src/toolchain.rs
Lines 283 to 329 in 28d1352
rami3l commentedon Mar 5, 2026
@Bogay I think if the attacker cannot write arbitrary output into our error message then we'd be good. Although I know
io::Erroris open-ended, it seems thatCommand::spawn()can only throw some of them, so you have a very limited set of output to handle.Would you mind submitting a PR (even in draft state) so we can have a further look?
Bogay commentedon Mar 5, 2026
@rami3l Sure, I have opened a draft PR.
I agree that the error messages can be improved for some common cases. However, I am not sure which errors should be handled. As per discussion in rust-lang/rust#108213, it seems that rust std does not guarantee returned errors of those methods.
sftse commentedon Apr 9, 2026
Is there a reason why
unknown-linux-muslwould error on Linux whileunknown-linux-gnusucceeds?rami3l commentedon Apr 9, 2026
@sftse See #3254 (comment) and rust-lang/rust#108907.
The TLDR is to install the
musltarget, not themusltoolchain, on your system.