Skip to content

cargo why <crate> #10006

Closed as not planned
Closed as not planned

Description

@homersimpsons

Problem

It is hard to know why a specific crate is required (and why it has a specific version).

Proposed Solution

There could be a sub command named why that could display the constraints applied to a crate and the dependency tree linked to it in order to understand why a specific crate is required.

Composer (PHP's package manager) exposes such sub command: https://getcomposer.org/doc/03-cli.md#depends-why-

Notes

This issue should be flagged with A-new-subcommand I guess.

A "similar" issue exists #1211 but it does not have the same intent

Activity

  1. added
    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
    on Oct 24, 2021
  2. changed the title [-]`cargo why <crate>` package[/-] [+]`cargo why <crate>`[/+] on Oct 24, 2021
  3. weihanglo commented on Nov 10, 2021

    @weihanglo
    Member

    cargo-tree covers some usages here. For example. run cargo tree -i curl shows the reversed dependency tree:

    curl v0.4.40
    ├── cargo v0.59.0 (/dev/cargo)
    ├── crates-io v0.33.0 (/dev/cargo/crates/crates-io)
    │   └── cargo v0.59.0 (/dev/cargo)
    └── git2-curl v0.14.1
        └── cargo v0.59.0 (/dev/cargo)

    The tree command also supports showing enabled features for dependencies. But unfortunately, it doesn't cover "why it has a specific version" as you mentioned.

  4. homersimpsons commented on Nov 11, 2021

    @homersimpsons
    Author

    Oh, I didn't notice that you could invert cargo-tree. Thank you for this information !

  5. epage commented on Apr 20, 2022

    @epage
    Contributor

    Since we have cargo tree -i, do we still need this issue? Is there something we could do to make it easier to go from user problem ("why this dependency") to discovering cargo tree -i?

    Granted, for myself, I just use cargo tree | less and just search the output because I forget about -i (speaking of, maybe we should have pager support for cargo tree).

  6. epage commented on Oct 31, 2023

    @epage
    Contributor

    Closing this as covered by cargo tree. #12903 adds some more documentation around this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-new-subcommandArea: new subcommandC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions