@@ -172,11 +172,9 @@ dev = "/home/user/dev/rust/libraries/"
172
172
This will produce a ` path ` dependency ` foo ` located at
173
173
` /home/user/dev/rust/libraries/foo ` .
174
174
175
- If the base path is not found in any ` [base-paths] ` table or one of the built-in
176
- base paths then Cargo will generate an error.
177
-
178
- If the name of a base path is specified in both the manifest and configuration,
179
- then the value in the manifest is preferred.
175
+ Base paths can be either absolute or relative. Relative base paths are relative
176
+ to the parent directory of the configuration or manifest file that declared that
177
+ base path.
180
178
181
179
The name of a base path must use only [ alphanumeric] ( https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric )
182
180
characters or ` - ` or ` _ ` , must start with an [ alphabetic] ( https://doc.rust-lang.org/std/primitive.char.html#method.is_alphabetic )
@@ -188,17 +186,32 @@ Cargo provides implicit base paths that can be used without the need to specify
188
186
them in a ` [base-paths] ` table.
189
187
190
188
* ` workspace ` - If a project is [ a workspace or workspace member] ( https://doc.rust-lang.org/cargo/reference/workspaces.html )
191
- then this base path is defined as the path to the directory containing the root
192
- Cargo.toml of the workspace.
189
+ then this base path is defined as the parent directory of the root Cargo.toml of
190
+ the workspace.
191
+
192
+ #### Base paths resolution order
193
+
194
+ Cargo will search for base paths in the following order:
195
+
196
+ 1 . In the [ configuration] ( https://doc.rust-lang.org/cargo/reference/config.html ) .
197
+ 1 . In the [ manifest] ( https://doc.rust-lang.org/cargo/reference/manifest.html )
198
+ that is using the base path.
199
+ 1 . In the workspace's [ manifest] ( https://doc.rust-lang.org/cargo/reference/manifest.html ) .
200
+ 1 . In the list of built-in base paths.
201
+
202
+ If the base path is not found in during this search then Cargo will generate an
203
+ error.
193
204
194
- If one of these built-in base paths is also specified in the manifest or
195
- configuration, then that value is preferred over the built-in value. This allows
196
- Cargo to introduce additional built-in paths in the future without compatibility
197
- issues, as any existing uses will shadow Cargo's built-in name.
205
+ Once a base path is found Cargo will stop searching, thus it is possible to
206
+ shadow a base path by declaring it earlier in the search order. This allows the
207
+ user's configuration to override the base path in a package, or for Cargo to add
208
+ new built-in base paths without compatibility issues (as existing uses will
209
+ shadow the built-in name).
198
210
199
211
## The Manifest Format
200
212
201
- [ ` [base-paths] ` ] ( https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#base-paths ) - Base paths for path dependencies.
213
+ * Dependency tables:
214
+ * [ ` [base-paths] ` ] ( https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#base-paths ) - Base paths for path dependencies.
202
215
203
216
## Configuration
204
217
0 commit comments