Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a better error message when the version output can't be parsed #33

Closed
jyn514 opened this issue Nov 7, 2020 · 4 comments
Closed

Comments

@jyn514
Copy link

jyn514 commented Nov 7, 2020

Currently, when the version output isn't recognized, rustc_version gives an error like this:

thread 'main' panicked at 'failed to determine underlying rustc version of Miri: UnexpectedVersionFormat', src/tools/miri/cargo-miri/bin.rs:132:38

However this is very unhelpful for determining the actual issue, which is that the dynamic libraries were not set up correctly:

/home/r/src/rust/rustc.3/build/x86_64-unknown-linux-gnu/stage0-tools-bin/miri: error while loading shared libraries: libLLVM-11-rust-1.49.0-nightly.so: cannot open shared object file: No such file or directory

It would be great to either print the full output of the command on failure, or to store it in the error message so the library user can report it themselves.

@RalfJung
Copy link
Contributor

RalfJung commented Nov 7, 2020

rustc_version gives an error like this:

To be clear, that is the error one gets when doing expect on the Result returned by rustc_version.
But indeed it'd be great if the error enum contained some more details, such as the text it failed to parse.

However, that would not even have been useful in this case -- the text is empty. What would have been useful is if for_command checked the exit code of the process, and in case of failure, provided stderr (and maybe also stdout) as part of the error.

@djc
Copy link
Owner

djc commented Nov 8, 2020

So just for my context -- miri is relying on this crate? That's good to know. (It doesn't show up as a dependent crate on crates.io, since I guess it's used as a path dependency inside the compiler repo?)

@jyn514
Copy link
Author

jyn514 commented Nov 8, 2020

@djc crates.io only shows crates that have been published to crates.io, and miri hasn't. miri isn't using a path dependency, it's just downloading from crates.io normally.

@RalfJung
Copy link
Contributor

RalfJung commented Nov 8, 2020

Yes, Miri -- or rather, its cargo wrapper -- depends on rustc_version to determine the default target of the toolchain it is running in.

Thanks a lot for making that so easy. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants