cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Overriding config through nested aliases does not work

Open DaniPopes opened this issue 1 year ago • 3 comments

Problem

Passing --config ... inside of a cargo alias, and using that with another cargo alias does not work.

Steps

  1. cargo new test; cd test
  2. .cargo/config.toml
[alias]
my_alias = '--config build.rustflags=["--invalid"]'
  1. cargo my_alias c passes, but cargo my_alias check fails, indicating that the --config is not propagated through the c = check alias

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.79.0-nightly (c93926759 2024-04-23)
release: 1.79.0-nightly
commit-hash: c9392675917adc2edab269eea27c222b5359c637
commit-date: 2024-04-23
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Manjaro 23.1.4 (Vulcan) [64-bit]

DaniPopes avatar Apr 29 '24 00:04 DaniPopes

@rustbot label +A-aliases

heisen-li avatar Apr 29 '24 03:04 heisen-li

Currently, the context is loaded in two phases

  • GlobalContext::new at app start
  • GlobalContext::configure once the whole command-line has been parsed.

This would require us to add a third phase and correctly merge it in. The most likely to get wrong part is related to verbosity

epage avatar Apr 29 '24 15:04 epage

This seems to be an unsupported behavior that is accidentally supported. From the [alias] doc:

The value may be an array of strings, where the first element is the command and the following are arguments. It may also be a string

We may need to figure out since when it started working, and consider either banning or officially supportting it.

weihanglo avatar May 02 '24 21:05 weihanglo