-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP] Fix: Cargo fails to detect environment variable #13596
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use r? to explicitly pick a reviewer |
I would expect this detection to be in the fingerprint code. There is code there already for managing changes in environment variables. Can you say why the current fingerprinting code is not catching this case? |
@ehuss |
And agree with Eric on this being fixed in fingerprint. |
Thanks to @weihanglo for the additional explanation, it has been added to |
@rustbot ready |
let dirty_reason = match dirty_reason { | ||
Some(dr) => dr, | ||
None => { | ||
let Some(dr) = env_config_modified(bcx.gctx) else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this does fix the case described in #13280, the actual problem is not addressed: Dep-info from Cargo doesn't track # env-var:
from rustc's dep-info files.
It's simple to reproduce delete the .cargo/config.toml
from the case in #13280, then run
cargo r --config 'env.Z="1"'
cargo r --config 'env.Z="2"'
cargo r --config 'env.Z="3"'
Only Z=1
would be captured, and Cargo never recompile after the first invocation. Hence, the current patch just solves half of it and buries the real bug deeper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder some alternatives may be like:
- Have a set of environment variables Cargo internally sets for rustc, and removes them from Cargo's dep info here. This might need to take
cargo::rustc-env
build script directive into account, and I feel it will be pretty error-prone as we might miss something when adding more envs. - Leverage the unstable
--env-set
rustc flag from the env sandboxing RFC. However, it is still unstable so Cargo can't use it.
@LuuuXXX are you still interested in moving this forward? |
@rustbot author |
Sorry for missing message,I apologize for not having the time to work on it in the coming month,a few things are tripping me up. |
☔ The latest upstream changes (presumably #14137) made this pull request unmergeable. Please resolve the merge conflicts. |
Going to close due to inactivity. We are still interested in some solutions here. Feel free to reopen if you have a chance to work on it again. |
What does this PR try to resolve?
Fixes: #13280
Cargo fails to detect and rebuild while using environment variable reset environment variable which is set in
config.toml
.examples:
.cargo/config.toml:
src/main.rs:
run these commands:
How should we test and review this PR?
checkout and run test:
Additional information
Fingerprint code is not able to detect environment variables cause they were removed from Cargo's dep-info. See #13280 (comment).