@@ -7,8 +7,10 @@ result of the resolution is stored in the `Cargo.lock` file which "locks" the
7
7
dependencies to specific versions, and keeps them fixed over time.
8
8
9
9
The resolver attempts to unify common dependencies while considering possibly
10
- conflicting requirements. The sections below provide some details on how these
11
- constraints are handled, and how to work with the resolver.
10
+ conflicting requirements. Dependency resolution is, however, an NP-hard problem,
11
+ and so the resolver uses a heuristic algorithm that may yield counterintuitive
12
+ results in some cases. The sections below provide some details on how
13
+ requirements are handled, and how to work with the resolver.
12
14
13
15
See the chapter [ Specifying Dependencies] for more details about how
14
16
dependency requirements are specified.
@@ -91,6 +93,31 @@ at the time of this writing) and Package B will use the greatest `0.6` release
91
93
(` 0.6.5 ` for example). This can lead to potential problems, see the
92
94
[ Version-incompatibility hazards] section for more details.
93
95
96
+ The resolver algorithm favors the greatest available versions of dependencies
97
+ and has limited support for backtracking in the solutions it attempts.
98
+ Therefore, it may converge on a solution that includes two copies of a
99
+ dependency when one would suffice. For example:
100
+
101
+ ``` toml
102
+ # Package A
103
+ [dependencies ]
104
+ rand = " 0.7"
105
+
106
+ # Package B
107
+ [dependencies ]
108
+ rand = " >=0.6"
109
+ ```
110
+
111
+ In this example, Cargo may build two copies of the rand crate: ` 0.8.5 ` (the
112
+ greatest available at the time of this writing) for Package B and ` 0.7.3 ` for
113
+ Package A — even though a single copy at version ` 0.7.3 ` meets all requirements.
114
+ Future revisions of the resolver algorithm may change this behavior. In the
115
+ meantime, the [ ` cargo update ` ] command with the ` --precise ` flag can be used to
116
+ manually remove such duplications.
117
+
118
+ [ `cargo update` ] : ../commands/cargo-update.md
119
+
120
+
94
121
Multiple versions within the same compatibility range are not allowed and will
95
122
result in a resolver error if it is constrained to two different versions
96
123
within a compatibility range. For example, if there are two packages in the
0 commit comments