rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.87k stars 12.52k forks source link

Tracking issue for `--env-set` flag #118372

Open GuillaumeGomez opened 9 months ago

GuillaumeGomez commented 9 months ago

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

tgross35 commented 8 months ago

Ongoing zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Stabilizing.20.60--env.60.20option.20flag.3F

GuillaumeGomez commented 8 months ago

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

fenollp commented 3 weeks ago

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

My 2cents on a couple points:

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