Skip to content
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

cargo metadata output shouldn't filter by target in .cargo/config #8462

Open
ComputerDruid opened this issue Jul 7, 2020 · 1 comment
Open
Labels
C-bug Category: bug Command-metadata regression-from-stable-to-stable Regression in stable that worked in a previous stable release. S-triage Status: This issue is waiting on initial triage.

Comments

@ComputerDruid
Copy link

Problem

When a conditional dependency exists in Cargo.toml:

[target.'cfg(not(target_os = "fuchsia"))'.dependencies]
smol = "0.1.11"

and a .cargo/config exists which sets a default target:

[build]
target = "x86_64-fuchsia"

The output of cargo metadata --format-version 1 is missing the dependencies pulled in by the conditional dep, but they shouldn't be.

Steps

$ cargo init cargo_metadata_example
$ cd cargo_metadata_example
$ cat <<EOF >> Cargo.toml
[target.'cfg(not(target_os = "fuchsia"))'.dependencies]
smol = "0.1.11"
EOF
$ mkdir .cargo
$ echo -e '[build]\ntarget = "x86_64-fuchsia"' > .cargo/config

$ cargo +beta metadata --format-version 1 | jq '.packages[] | .id' # Broken:
"cargo_metadata_example 0.1.0 (path+file:///usr/local/google/home/computerdruid/cargo_metadata_example)"

$ cargo +stable metadata --format-version 1 | jq '.packages[] | .id' # Works:
"pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)"
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)"
"concurrent-queue 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)"
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)"
"cargo_metadata_example 0.1.0 (path+file:///usr/local/google/home/computerdruid/cargo_metadata_example)"
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)"
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)"
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)"
"futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)"
"parking 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)"
"blocking 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)"
"cache-padded 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)"
"cc 1.0.57 (registry+https://github.com/rust-lang/crates.io-index)"
"futures-io 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)"
"once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)"
"async-task 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)"
"smol 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)"
"pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)"
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)"
"futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)"
"futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)"
"futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)"
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)"
"libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)"
"scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)"
"futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)"
"socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)"
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)"
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)"
"pin-project-internal 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)"
"waker-fn 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)"
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)"
"syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)"
"fastrand 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)"
"wepoll-sys-stjepang 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)"

Notes

Output of cargo version:

$ cargo +beta --version
cargo 1.45.0-beta (744bd1fbb 2020-06-15)
$ cargo +stable --version
cargo 1.44.1 (88ba85757 2020-06-11)
  • I also tested on nightly, it has the same bug.
  • I used jq in the reproduction to make the output smaller and show what's missing, but jq isn't an important part of the repro, you can see the problem just by looking at the json output.
@tmandry
Copy link
Member

tmandry commented Jul 28, 2020

This was a stable-to-beta regression and is now a stable-to-stable regression, I think it needs to be marked as such.

@ehuss ehuss added the regression-from-stable-to-stable Regression in stable that worked in a previous stable release. label Jul 28, 2020
@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-metadata regression-from-stable-to-stable Regression in stable that worked in a previous stable release. S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

4 participants