-
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
Unhelpful error messages with env-vars that don't set all fields of a config struct #13688
Comments
Thanks for the report. I guess this is not a general issue but |
Those do appear to be the only structs in the unstable config. I'm not sure where the general config-env-var parsing happens so I'm not certain if they're the only ones that are affected. |
Found a way to trigger it with a stable config too: > CARGO_TERM_PROGRESS_WIDTH=2 cargo check
error: missing field `when` |
FYI, I have searched the code base, and have not found the place that triggers missing field, guess that this is related to the parsing process of the third-party library serde? |
Yeah, the env-vars are read as part of a deserializer that merges the config files, env-vars and cli flags into one, then the error is produced by the > cargo check --config 'term.progress.width=2'
error: missing field `when`
> mkdir -p .cargo && echo 'term.progress.width=2' > .cargo/config.toml
> cargo check
error: missing field `when` What would be most useful is more context on the error: what's the full config key that's being parsed and failed, and where are the other fields coming from (they can even come from multiple locations: > CARGO_TERM_PROGRESS_WIDTH=2 cargo check --config 'term.progress.when="always"'
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s |
Whats interesting about the config case is that its |
See #13694 to see what that looks like |
It looks like this is being tracked in the cargo/src/cargo/util/context/de.rs Line 315 in 18181c6
it feels like it should be possible to attach this context somewhere at this level when the error first passes back to the deserializer. |
Good point. I do something similar in However, I hit my time box I set aside for this as I need to be wrapping up some existing tasks and putting most of my focus to my 2024 Edition work. |
Problem
I have been using the
gitoxide
integration for a while, via setting env-vars so it doesn't impact running the stable compiler:After updating to a version that includes #13592 any usage of cargo starts failing with
which makes no mention of where this field is missing
Steps
Possible Solution(s)
No response
Notes
#13687 will likely fix this specific issue by making the fields of this struct default, but the general issue of the error message not having enough context will remain.
Version
The text was updated successfully, but these errors were encountered: