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
or one of the [built-in base paths](#built-in-base-paths). The value of that
155
+
base path is prepended to the `path` value to produce the actual location where
156
+
Cargo will look for the dependency.
103
157
104
-
The `[base_path]` table defines a set of path prefixes that can be used to
105
-
prepend the locations of `path` dependencies. Each key in the table is the name
106
-
of the base path and the value is the actual file system path. These base paths
107
-
can be used in a `path` dependency by setting its `base` key to the name of the
108
-
base path to use.
158
+
For example, if the Cargo.toml contains:
109
159
110
160
```toml
111
-
[base_path]
112
-
dev = "/home/user/dev/rust/libraries/"
161
+
[dependencies]
162
+
foo = { path = "foo", base = "dev" }
113
163
```
114
164
115
-
The "dev" base path may then be referenced in a `Cargo.toml`:
165
+
Given a `[base-paths]` table in the configuration that contains:
116
166
117
167
```toml
118
-
[dependencies]
119
-
foo = { path = "foo", base = "dev" }
168
+
[base-paths]
169
+
dev = "/home/user/dev/rust/libraries/"
120
170
```
121
171
122
-
To produce a `path` dependency `foo` located at
172
+
This will produce a `path` dependency `foo` located at
123
173
`/home/user/dev/rust/libraries/foo`.
124
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.
125
177
126
-
## Specifying Dependencies
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.
127
180
128
-
A `path` dependency may optionally specify a base path by setting the `base` key
129
-
to the name of a base path from the `[base_path]` table in the configuration.
130
-
The value of that base path in the configuration is prepended to the `path`
131
-
value to produce the actual location where Cargo will look for the dependency.
181
+
The name of a base path must use only [alphanumeric](https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric)
182
+
characters or `-` or `_`, and cannot be empty.
132
183
133
-
If the base path is not found in the `[base_path]` table then Cargo will
134
-
generate an error.
184
+
#### Built-in base paths
135
185
136
-
```toml
137
-
[dependencies]
138
-
foo = { path = "foo", base = "dev" }
139
-
```
186
+
Cargo provides implicit base paths that can be used without the need to specify
187
+
them in a `[base-paths]` table.
140
188
141
-
Given a `[base_path]` table in the configuration that contains:
189
+
*`workspace` - If a project is [a workspace or workspace member](https://doc.rust-lang.org/cargo/reference/workspaces.html)
190
+
then this base path is defined as the path to the directory containing the root
191
+
Cargo.toml of the workspace.
142
192
143
-
```toml
144
-
[base_path]
145
-
dev = "/home/user/dev/rust/libraries/"
146
-
```
193
+
If one of these built-in base paths is also specified in the manifest or
194
+
configuration, then that value is preferred over the built-in value.
147
195
148
-
Will then produce a `path` dependency `foo` located at
149
-
`/home/user/dev/rust/libraries/foo`.
196
+
## The Manifest Format
197
+
198
+
[`[base-paths]`](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#base-paths) - Base paths for path dependencies.
199
+
200
+
## Configuration
201
+
202
+
`[base-paths]`
203
+
204
+
* Type: string
205
+
* Default: see below
206
+
* Environment: `CARGO_BASE_PATHS_<name>`
207
+
208
+
The `[base-paths]` table defines a set of path prefixes that can be used to
209
+
prepend the locations of `path` dependencies. See the [specifying dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#base-paths)
0 commit comments