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

Environment variable for the Rust version #4408

Open
stanislav-tkach opened this issue Aug 17, 2017 · 6 comments
Open

Environment variable for the Rust version #4408

stanislav-tkach opened this issue Aug 17, 2017 · 6 comments
Labels
A-environment-variables Area: environment variables C-enhancement Category: enhancement S-triage Status: This issue is waiting on initial triage.

Comments

@stanislav-tkach
Copy link
Contributor

stanislav-tkach commented Aug 17, 2017

Cargo sets some environment variables, for example, CARGO_PKG_VERSION. I suppose it will be handy to have environment variable with the Rust version.

I would like to try to add it if it is appropriate.

See also #2903

@alexcrichton
Copy link
Member

Thanks for the report! I'm not sure we're quite ready to do this in the sense that it would entail parsing the output of rustc -vV, which I'm not sure is a "stable" format right now.

@stanislav-tkach
Copy link
Contributor Author

For my purpose it will be OK to have a version in any format: I'm trying to form some "user agent" string in our application that should include the Rust version. But I understand that such solution may not be appropriate for the Cargo. I can still get the Rust version inside build.rs anyway. Do you think that it makes no sense to have such functionality in the Cargo right now?

@alexcrichton
Copy link
Member

Nah I think eventually we may wish to expose this, but I'd prefer to ensure there's a stable method for Cargo to learn the compiler's version info (e.g. a structured format) before we expose it.

@dwijnand
Copy link
Member

dwijnand commented Feb 1, 2019

RFC rust-lang/rfcs#2523 might be of interest, as it proposes #[cfg(version(1.27))].

@dekellum
Copy link
Contributor

dekellum commented Feb 2, 2019

See also the version_check crate. See the nom crate's build.rs for good example of using it.

@ehuss ehuss added the A-environment-variables Area: environment variables label Sep 23, 2019
@epage epage added the S-triage Status: This issue is waiting on initial triage. label Sep 28, 2023
@epage
Copy link
Contributor

epage commented Oct 17, 2023

Looking back at this, this request is for the string being available for process and is independent of then using that in build.rs for conditional compilation, which is what #2903 is about.

If we did this, I'd either want rust-lang/rfcs#2523 stabilized first and/or to disallow this env varaible in build scripts so it doesn't become an alternative mechanism to rust-lang/rfcs#2523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-environment-variables Area: environment variables C-enhancement Category: enhancement S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

7 participants