-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Setting target.runner via --config twice concatenates lists #10893
Comments
@rustbot claim |
I think this is a feature, not a bug. /// A config type that is a program to run.
///
/// This supports a list of strings like `['/path/to/program', 'somearg']`
/// or a space separated string like `'/path/to/program somearg'`.
///
/// This expects the first value to be the path to the program to run.
/// Subsequent values are strings of arguments to pass to the program.
///
/// Typically you should use `ConfigRelativePath::resolve_program` on the path
/// to get the actual program.
#[derive(Debug, Clone)]
pub struct PathAndArgs {
pub path: ConfigRelativePath,
pub args: Vec<String>,
} So cargo treats the second |
But when would that be what you want? When using the env var CARGO_RUNNER, it correctly overwrites the value it would otherwise use. That used to also concatenate, but in #8629 the old behavior was deemed incorrect. |
Could you try I think it will use the last one and overwrite the second one. Also you can try It will use the last one. |
I believe this is being released on stable in 2 days which will likely limit what we can change about this |
There's still room for any patches, but please communicate closely with me (over Zulip, most likely) if the Cargo team would like to adjust things. |
For now, [target.'cfg(all())']
runner = ["run1","run3"] I'm not sure if should we change the behavior. |
If you try to add this config and also pass the CLI args, it will be concatenated. [target.'cfg(all())']
runner = ["run1","run2"]
You will get And if you use the config and env variable, it won't be concatenated.
|
This is long stable via #8629 changed stable behavior AFAIK? |
Oh interesting, this is rejected in config.toml:
So it is somewhat strange that it is accepted in However, if I have this in my
and this in my local
Then it also merges the lists. So It is about how cargo "merges" the value when it has a value set in different sources. Currently it is inconsistent:
I would expect "merging" to treat the env var as just another source, and do merging in the same way as it is done elsewhere. And for this specific case of the
There is no |
Oops, I posted the out-of-date config and command. updated. |
Right, so all the different toml sources get concatenated together. Having When one tries using different
|
Hm, but there also seems to be a bug in
it entirely ignores the So arguably So I think there are two bugs:
|
Could you indicate which ones? Do you mean |
I agree. It's confusing. |
|
I found that this is a bug in |
Cargo works well with the second one. But it will not report an error for the first one. We ignore the parse error in: /// Utility function to check if the key, "cfg(..)" matches the `target_cfg`
pub fn matches_key(key: &str, target_cfg: &[Cfg]) -> bool {
if key.starts_with("cfg(") && key.ends_with(')') {
let cfg = &key[4..key.len() - 1];
CfgExpr::from_str(cfg)
// **Here**
.ok()
.map(|ce| ce.matches(target_cfg))
.unwrap_or(false)
} else {
false
}
} Do you think we should report the error for it? |
Oh, good catch! What happens when a config file omits the
|
Same. It will be ignored. |
Okay. Yeah seems better to report parse errors to the user but this could be a breaking change. |
@epage What do you think? |
I tried to add some warnings in Does anyone have any ideas about how to fix or improve it? |
Maybe we can move this function out. |
Actually I see |
Good catch! Yes I believe #15066 has fixed this issue. Closing. |
Consider the following invocation:
This fails saying
I think there is a bug here: cargo tried to execute
run run ...
, i.e., it concatenated the two configs I gave! I would have expected the second config to overwrite the first, similar to what happens since #8629 when the runner is set both in cargo.toml and via the env var.The text was updated successfully, but these errors were encountered: