rust-lang / cargo

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

dependency is listed only with `-e normal,dev` but not with `-e normal` or `-e dev` #14114

Closed themighty1 closed 2 months ago

themighty1 commented 3 months ago

Problem

The dependency is listed only when running cargo tree -e normal,dev. When running either cargo tree -e normal or cargo tree -e dev it is not listed.

Steps

To reproduce:

git clone https://github.com/tlsnotary/tlsn
cd tlsn/components/tls/tls-mpc/
git checkout 68b9474015b817255c226fec38e80addd16191d1
cargo tree -e normal,dev | grep mio
cargo tree -e normal | grep mio
cargo tree -e dev | grep mio

You will only see that the dependency was found on the first invocation of cargo tree but not found on the 2nd or the 3rd.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
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: Ubuntu 22.4.0 (jammy) [64-bit]
epage commented 3 months ago
$ cargo tree -e normal,dev -i mio
mio v0.8.11
└── tokio v1.38.0
    ├── h2 v0.3.26
    │   └── hyper v0.14.29
    │       └── tls-server-fixture v0.0.0 (/home/epage/src/personal/dump/tlsn/components/tls/tls-server-fixture)
    │           [dev-dependencies]
    │           └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    ├── hyper v0.14.29 (*)
    ├── tls-server-fixture v0.0.0 (/home/epage/src/personal/dump/tlsn/components/tls/tls-server-fixture) (*)
    ├── tlsn-utils-aio v0.1.0 (https://github.com/tlsnotary/tlsn-utils?rev=51f313d#51f313d1)
    │   ├── mpz-garble v0.1.0 (https://github.com/privacy-scaling-explorations/mpz?rev=9f7403b#9f7403be)
    │   │   ├── tlsn-aead v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/aead)
    │   │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   ├── tlsn-block-cipher v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/cipher/block-cipher)
    │   │   │   ├── tlsn-aead v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/aead) (*)
    │   │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   ├── tlsn-hmac-sha256 v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/prf/hmac-sha256)
    │   │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   ├── tlsn-key-exchange v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/key-exchange)
    │   │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   ├── tlsn-stream-cipher v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/cipher/stream-cipher)
    │   │   │   ├── tlsn-aead v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/aead) (*)
    │   │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   ├── mpz-ot v0.1.0 (https://github.com/privacy-scaling-explorations/mpz?rev=9f7403b#9f7403be)
    │   │   ├── mpz-garble v0.1.0 (https://github.com/privacy-scaling-explorations/mpz?rev=9f7403b#9f7403be) (*)
    │   │   ├── mpz-share-conversion v0.1.0 (https://github.com/privacy-scaling-explorations/mpz?rev=9f7403b#9f7403be)
    │   │   │   ├── tlsn-point-addition v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/point-addition)
    │   │   │   │   ├── tlsn-key-exchange v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/key-exchange) (*)
    │   │   │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   │   ├── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   │   └── tlsn-universal-hash v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/universal-hash)
    │   │   │       ├── tlsn-aead v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/aead) (*)
    │   │   │       └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   │   └── tlsn-key-exchange v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/key-exchange) (*)
    │   │   [dev-dependencies]
    │   │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   ├── mpz-share-conversion v0.1.0 (https://github.com/privacy-scaling-explorations/mpz?rev=9f7403b#9f7403be) (*)
    │   ├── tlsn-aead v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/aead) (*)
    │   ├── tlsn-hmac-sha256 v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/prf/hmac-sha256) (*)
    │   ├── tlsn-key-exchange v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/key-exchange) (*)
    │   ├── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    │   └── uid-mux v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/uid-mux)
    │       [dev-dependencies]
    │       └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    └── tokio-util v0.7.11
        ├── h2 v0.3.26 (*)
        ├── tls-server-fixture v0.0.0 (/home/epage/src/personal/dump/tlsn/components/tls/tls-server-fixture) (*)
        ├── tlsn-tls-client-async v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-client-async)
        │   [dev-dependencies]
        │   └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
        └── tlsn-utils-aio v0.1.0 (https://github.com/tlsnotary/tlsn-utils?rev=51f313d#51f313d1) (*)
        [dev-dependencies]
        └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
    [dev-dependencies]
    └── tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
epage commented 3 months ago

mio is an optional dependency of tokio if net, process, or signal features are enabled

epage commented 3 months ago

Helps if I look at the most basic output

❯ cargo tree -e dev
tlsn-tls-mpc v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-mpc)
[dev-dependencies]
├── mpz-ot v0.1.0 (https://github.com/privacy-scaling-explorations/mpz?rev=9f7403b#9f7403be)
├── tls-server-fixture v0.0.0 (/home/epage/src/personal/dump/tlsn/components/tls/tls-server-fixture)
├── tlsn-tls-client v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-client)
├── tlsn-tls-client-async v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/tls/tls-client-async)
├── tokio v1.38.0
├── tokio-util v0.7.11
├── tracing-subscriber v0.3.18
└── uid-mux v0.1.0-alpha.5 (/home/epage/src/personal/dump/tlsn/components/uid-mux)

Notice that this doesn't go any deeper. It looks like -e dev doesn't show "what are my dependencies when I do a dev build" but include the dev edges". To see all of your dev-dependencies, you also have to look at their normal dependencies.

themighty1 commented 3 months ago

@epage , thanks for looking into this. I just want to make sure: are you confirming that this is a bug or is this the expected behaviour?

themighty1 commented 3 months ago

Note that if you run cargo tree -e normal,dev,features | grep mio -A10 -B10 you will see this snippet

│   │   │   │       │   ├── tokio feature "default"
│   │   │   │       │   │   └── tokio v1.38.0
│   │   │   │       │   │       ├── mio v0.8.11

which shows that cargo thinks that mio is a dep of tokio with the default feature. This is wrong - mio is an optional dep.

I don't know if this is a separate bug or whether it is related to this one.

epage commented 2 months ago

I just want to make sure: are you confirming that this is a bug or is this the expected behaviour?

@ehuss, any thoughts on this? I can see both an argument for -e dev only showing you direct dependencies, because that is literally what you asked for, but most likely the user intended to see the normal and build dependencies associated with their dev-dependencies.

ehuss commented 2 months ago

Sorry I don't have a particularly good answer. In short, this is expected behavior. "Show dev-dependencies and their normal dependencies, but not my normal dependencies" wasn't a use case I think we considered (or at least seemed important).

themighty1 commented 2 months ago

Thanks for trying to resolve this but it seems to me like we started to talk past each other at some point, maybe because I didn't articulate my question precisely.

My question can be distilled into: When comparing the output of -e normal,dev and the concatenation of outputs from -e normal and -e dev, I can see that -e normal,dev outputs some extra information (as per my OP).

So far I understood that: -e dev -> show my dev dependencies and don't go any deeper. (i.e. don't show the deps of my dev deps) -e normal -> show my normal deps and also the deps of my normal deps. -e normal,dev -> show my normal+dev deps and also the deps of all the normal+dev deps

So, the extra info shown by -e normal,dev (which is not shown by concatenating -e normal and -e dev) is the deps of my dev deps? Is that correct?

ehuss commented 2 months ago

Yes, that sounds correct to me.

themighty1 commented 2 months ago

Thank you, it's all clear now. Seems like the fact that mio shows as a dependency of tokio with the default feature is an unrelated issue. I'll open a new issue for that.