Skip to content

Commit

Permalink
docs(ref): Highlight commands to answer dep resolution questions
Browse files Browse the repository at this point in the history
Previously, in the #6666, the aptly named `cargo lucifer` was suggested
for answering resolver questions.

Turns out most of these can be answered now, between logging and `cargo
tree`.
This adds troubleshooting tips to help highlight the use of
these commands to answer these questions.

Fixes #6666
  • Loading branch information
epage committed Oct 31, 2023
1 parent 4aee12c commit 086d16c
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion src/doc/src/reference/resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,43 @@ break the build.
The following illustrates some problems you may experience, and some possible
solutions.

### Why was a dependency included?

Say you see dependency `rand` in the `cargo check` output but don't think its needed and want to understand why its being pulled in.

You can run
```console
$ cargo tree --workspace --target all --all-features --invert rand
rand v0.8.5
└── ...

rand v0.8.5
└── ...
```

You might identify that it was an activated feature that caused `rand` to show up. To figure out which package activated the feature, you can add the `--edges features`
```console
$ cargo tree --workspace --target all --all-features --edges features --invert rand
rand v0.8.5
└── ...

rand v0.8.5
└── ...
```

### Unexpected dependency duplication

The resolver algorithm may converge on a solution that includes two copies of a
You see multiple instances of `rand` when you run
```console
$ cargo tree --workspace --target all --all-features --duplicates
rand v0.7.3
└── ...

rand v0.8.5
└── ...
```

The resolver algorithm has converged on a solution that includes two copies of a
dependency when one would suffice. For example:

```toml
Expand All @@ -517,6 +551,17 @@ But, if you run into this situation, the [`cargo update`] command with the

[`cargo update`]: ../commands/cargo-update.md

### Why wasn't a newer version selected?

Say you noticed that the latest version of a dependency wasn't selected when you ran:
```console
$ cargo update
```
You can enable some extra logging to see why this happened:
```console
$ env CARGO_LOG=cargo::core::resolver=trace cargo update
```
**Note:** Cargo log targets and levels may change over time.

### SemVer-breaking patch release breaks the build

Expand Down

0 comments on commit 086d16c

Please sign in to comment.