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

fix(env): cargo:rerun-if-env-changed doesn't work with env configuration #14058

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

heisen-li
Copy link
Contributor

What does this PR try to resolve?

Fixes #10358

Additional information

Due to my stupidity, I screwed up the previous PR. I didn't know what to do with it, so I created a new PR.

r?@epage

@rustbot rustbot added A-cfg-expr Area: Platform cfg expressions A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 13, 2024
@heisen-li heisen-li changed the title Config env changefix(env): cargo:rerun-if-env-changed doesn't work with env configuration fix(env): cargo:rerun-if-env-changed doesn't work with env configuration Jun 13, 2024
@epage
Copy link
Contributor

epage commented Jun 26, 2024

btw I believe this would also fix #8693.

This would likely need to revert #12482.

@heisen-li heisen-li force-pushed the config_env_change branch 3 times, most recently from c422491 to 08bbb58 Compare July 1, 2024 08:39
} else {
envs.get(key).and_then(|v| v.to_owned())
}
.xor(env::var_os(key))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this before, why are we using xor rather than or?


#[cfg(windows)]
#[cargo_test]
fn rerun_if_env_changes_config_in_windows() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add all tests in commits before any functionality changes?

#[allow(clippy::disallowed_methods)]
fn from_env<K: AsRef<str>>(key: K) -> LocalFingerprint {
let key = key.as_ref();
fn from_env<K: AsRef<str>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would likely need to revert #12482.

Don't we need to update the documentation with this?

@epage epage added the T-cargo Team: Cargo label Jul 5, 2024
@@ -5,6 +5,109 @@ use cargo_test_support::project;
use cargo_test_support::sleep_ms;
use cargo_test_support::str;

#[cargo_test]
fn rerun_if_env_changes_config() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw I believe this would also fix #8693.

Since we should be getting that fix "for free", could you add a test for a cargo-set env variable (don't think it has to literally be that one) and mark this PR as fixing that issue as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cfg-expr Area: Platform cfg expressions A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cargo Team: Cargo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo:rerun-if-env-changed doesn't work with env configuration
5 participants