-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
A-dep-infoArea: dep-info, .d filesArea: dep-info, .d filesA-environment-variablesArea: environment variablesArea: environment variablesA-rebuild-detectionArea: rebuild detection and fingerprintingArea: rebuild detection and fingerprintingC-bugCategory: bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Description
Problem
The problem can be only reproduced if the environment variable is "not set" in the first run, and "set" in the second run.
Steps
Incorrect behaivor
.cargo/config.toml:
[env]
Z = "0"
src/main.rs:
fn main() {
println!("{:?}", option_env!("Z"));
}
run these commands:
cargo run # first build, output Some("0")
Z=1 cargo run # cargo does not notice the environment variable is set and runs it, output Some("0")
Correct behaivor if we do not use a config.toml
src/main.rs:
fn main() {
println!("{:?}", option_env!("Z"));
}
run these commands:
cargo run # first build, output None
Z=1 cargo run # cargo does know the environment variable is set and rebuilds it, output Some("1")
Correct behaivor if we change the environment variable from a value to another value
.cargo/config.toml:
[env]
Z = "0"
src/main.rs:
fn main() {
println!("{:?}", option_env!("Z"));
}
run these commands:
Z=2 cargo run # first build, output Some("2")
Z=1 cargo run # cargo does know the environment variable changes and rebuilds it, output Some("1")
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.77.0-nightly (ac6bbb332 2023-12-26)
cargo 1.75.0 (1d8b05cdd 2023-11-20)
Metadata
Metadata
Assignees
Labels
A-dep-infoArea: dep-info, .d filesArea: dep-info, .d filesA-environment-variablesArea: environment variablesArea: environment variablesA-rebuild-detectionArea: rebuild detection and fingerprintingArea: rebuild detection and fingerprintingC-bugCategory: bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review