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

How to get a version of rustc which is used by cargo? #2833

Closed
matklad opened this issue Jul 7, 2016 · 7 comments
Closed

How to get a version of rustc which is used by cargo? #2833

matklad opened this issue Jul 7, 2016 · 7 comments

Comments

@matklad
Copy link
Member

matklad commented Jul 7, 2016

Hi!

I'd like to show which version of rustc is used by cargo in IntelliJ GUI. Currently we just invoke /path_configured_by_user/cargo --version and /path_configured_by_user/rustc --version, but this may be wrong. For example, [the rustc may not be in PATH](not in path). Also there is RUSTC environment variable...

What do you think about extending cargo --version such that it also prints the version of the compiler, like this:

$ cargo --version --verbose
cargo 0.10.0-nightly (10ddd7d 2016-04-08)

rustc 1.9.0 (e4e8b6668 2016-05-18)
binary: rustc
commit-hash: e4e8b666850a763fdf1c3c2c142856ab51e32779
commit-date: 2016-05-18
host: x86_64-unknown-linux-gnu
release: 1.9.0

Looks like rustc version is queried anyway:

$ rm ~/.cargo/bin/rustc
$ ~/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo --version          
error: Could not execute process `rustc -vV` (never executed)

Caused by:
  No such file or directory (os error 2)

And maybe cargo --version should work even if there is no rustc available?

@matklad
Copy link
Member Author

matklad commented Jul 7, 2016

Ah, I must say that I can't use cargo rustc -- --version, because when you configure cargo you don't yet have a Cargo.toml.

@alexcrichton
Copy link
Member

Heh yeah today we have rustc --version on hand (it's parsed when Config is created) but I'd prefer if we didn't do that. That's just an implementation detail though, so we could change at any time!

I'd actually be fine I think if we printed out rustc --version as well when we ran cargo --version, so long as we make it clear which is which.

@brson what do you think?

@brson
Copy link
Contributor

brson commented Jul 7, 2016

I agree with the motivation, and can't think of anything smarter to do. Hopefully though we we don't need to do the same for rustdoc.

I think cargo --version should work when rustc doesn't exist. That's bitten me before.

@matklad
Copy link
Member Author

matklad commented Jul 25, 2016

I've though about it more and came to the conclusion that we probably don't want this feature.

As for the original motivation about IntelliJ Rust, we now always explicitly pass ( intellij-rust/intellij-rust#517 ) RUSTC environmental variable to Cargo and it works fine so far.

Knowing which rustc is used by Cargo can be useful for the end user to troubleshot problems, but I don't think that --version is the correct place to do this. Together with the compiler version we might want to output the path to the compiler, or the path to the configuration files or some other info. Something like cargo --show-config seems a better approach here.

But Cargo almost always just works, so there is no need to provide this functionality.

@matklad matklad closed this as completed Jul 25, 2016
@sesam
Copy link

sesam commented Nov 27, 2017

Sorry for commenting on an old issue.

I see this as an either or; either

  • cargo just works most of the time, so there's no harm in cargo also upgrading rustc to latest stable by itself; and whenever a cargo command fails it could check for newer releases and suggest upgrading.

or

  • versions are important, and Cargo.toml should allow package creators to say which versions are known good and known bad, so users don't have to rediscover this by guessing maybe rustup to latest, or to one before latest, or ...

Case: Several beta testers for https://github.com/mimblewimble/grin/ have vargo build fail with some hard to understand error, and all they would need is to get rustc >=1.21

Thanks for your time.

Workaround ideas very welcome.

EDIT: https://github.com/Kimundi/rustc-version-rs is NOT what I was looking for

@matklad
Copy link
Member Author

matklad commented Nov 27, 2017

@sesam I think the up-to-date discussion is here rust-lang/rfcs#2182

@sesam
Copy link

sesam commented Nov 27, 2017

Thanks, and sorry, it seems I pasted my comment on the wrong issue.

I noticed that RFCs get closed. Your suggested 2182 (closed), 1953 (closed), 1707 (closed).

For your own original issue, I guess you could solve that by heuristics, reimplementing the same rustc discovery and selection code that cargo already uses... which probably saves the cargo team a few code lines, and adds more code lines elsewhere.

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

4 participants