You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #12903 - epage:docs-deps, r=weihanglo
docs(ref): Highlight commands to answer dep resolution questions
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
Copy file name to clipboardexpand all lines: src/doc/src/reference/resolver.md
+46-1
Original file line number
Diff line number
Diff line change
@@ -489,9 +489,43 @@ break the build.
489
489
The following illustrates some problems you may experience, and some possible
490
490
solutions.
491
491
492
+
### Why was a dependency included?
493
+
494
+
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.
495
+
496
+
You can run
497
+
```console
498
+
$ cargo tree --workspace --target all --all-features --invert rand
499
+
rand v0.8.5
500
+
└── ...
501
+
502
+
rand v0.8.5
503
+
└── ...
504
+
```
505
+
506
+
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`
507
+
```console
508
+
$ cargo tree --workspace --target all --all-features --edges features --invert rand
509
+
rand v0.8.5
510
+
└── ...
511
+
512
+
rand v0.8.5
513
+
└── ...
514
+
```
515
+
492
516
### Unexpected dependency duplication
493
517
494
-
The resolver algorithm may converge on a solution that includes two copies of a
518
+
You see multiple instances of `rand` when you run
519
+
```console
520
+
$ cargo tree --workspace --target all --all-features --duplicates
521
+
rand v0.7.3
522
+
└── ...
523
+
524
+
rand v0.8.5
525
+
└── ...
526
+
```
527
+
528
+
The resolver algorithm has converged on a solution that includes two copies of a
495
529
dependency when one would suffice. For example:
496
530
497
531
```toml
@@ -517,6 +551,17 @@ But, if you run into this situation, the [`cargo update`] command with the
517
551
518
552
[`cargo update`]: ../commands/cargo-update.md
519
553
554
+
### Why wasn't a newer version selected?
555
+
556
+
Say you noticed that the latest version of a dependency wasn't selected when you ran:
557
+
```console
558
+
$ cargo update
559
+
```
560
+
You can enable some extra logging to see why this happened:
0 commit comments