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

Tracking issue for --env-set flag #118372

Open
1 of 3 tasks
GuillaumeGomez opened this issue Nov 27, 2023 · 3 comments
Open
1 of 3 tasks

Tracking issue for --env-set flag #118372

GuillaumeGomez opened this issue Nov 27, 2023 · 3 comments
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.

Comments

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Nov 27, 2023

Adds a new --env-set command line option on rustc. It allows to set environment variables value at compile-time to be used by env! and option_env! macros.

When retrieving and environment variable value, the one specified by --env-set will take precedence. For example if you want have PATH=a in your environment and pass --env-set PATH=env, then you will have:

assert_eq!(env!("PATH"), "env");

Steps

Unresolved questions

  • What is the desired behavior if the same --env variable is passed twice?
@GuillaumeGomez GuillaumeGomez added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Nov 27, 2023
@tgross35
Copy link
Contributor

@GuillaumeGomez
Copy link
Member Author

We discussed about how it might impact rust-lang/rfcs#2794 and decided to rename it into --env-set to prevent potential future issues.

@fenollp
Copy link

fenollp commented Aug 23, 2024

Hi! I see the stabilization PR was closed. What's the state of this then?

My 2cents on a couple points:

  • I need this so my $RUSTC_WRAPPER knows which envs to forward to rustc. Can't just forward all the envs.
  • same keys in duplicate --env-set KEY=.. should be an error. It resolves that point and allows forward compatibility

If help is needed here I'd like to provide some!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants