rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.55k stars 2.38k forks source link

`cargo --config 'k=v' <plugin>` isn't passed down to the plugin #11031

Open sunshowers opened 2 years ago

sunshowers commented 2 years ago

Problem

If someone runs the command:

cargo --config 'k=v' <plugin>

then the config isn't passed down to the plugin.

This was originally reported as https://github.com/nextest-rs/nextest/issues/498.

Steps

  1. Install nextest: https://nexte.st/book/pre-built-binaries.html
  2. Run cargo --config 'build.target-dir="foo"' nextest run
  3. See that the target dir is still target/.

(Note that cargo nextest run --config 'build.target-dir="foo"' works correctly, because nextest passes through Cargo configs.)

Possible Solution(s)

Best solution might be to pass configs down as an environment variable that plugins can read.

Notes

No response

Version

cargo 1.63.0 (fd9c4297c 2022-07-01)
release: 1.63.0
commit-hash: fd9c4297ccbee36d39e9a79067edab0b614edb5a
commit-date: 2022-07-01
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1n)
os: Pop!_OS 22.04 (jammy) [64-bit]
epage commented 2 years ago

If people are curious how git does this, https://github.com/gitext-rs/git-config-env/tree/main/src has a rough implementation of parts of it.

weihanglo commented 2 years ago

Semi-related:

I got an impression that cargo doesn't give external subcommands much info, even cargo-clippy can't inherit a jobserver from cargo today.