Skip to content

Commit 164a859

Browse files
committed
Clarify config-relative paths for --config <path>
1 parent 65332bc commit 164a859

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/doc/src/reference/config.md

+20-7
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,26 @@ precedence rules as other options specified directly with `--config`.
238238

239239
### Config-relative paths
240240

241-
Paths in config files may be absolute, relative, or a bare name without any
242-
path separators. Paths for executables without a path separator will use the
243-
`PATH` environment variable to search for the executable. Paths for
244-
non-executables will be relative to where the config value is defined. For
245-
config files, that is relative to the parent directory of the `.cargo`
246-
directory where the value was defined. For environment variables it is
247-
relative to the current working directory.
241+
Paths in config files may be absolute, relative, or a bare name without any path separators.
242+
Paths for executables without a path separator will use the `PATH` environment variable to search for the executable.
243+
Paths for non-executables will be relative to where the config value is defined.
244+
245+
In particular, rules are:
246+
247+
* For environment variables, paths are relative to the current working directory.
248+
* For config files, paths are relative to the parent directory of the directory where the config files were defined,
249+
no matter those files are from either the [hierarchical probing](#hierarchical-structure)
250+
or the [`--config <path>`](#command-line-overrides) option.
251+
252+
> **Note:** To maintain consistency with existing `.cargo/config.toml` probing behavior,
253+
> it is by design that a path in a config file passed via `--config <path>`
254+
> is also relative to two levels up from the config file itself.
255+
>
256+
> To avoid unexpected results, the rule of thumb is putting your extra config files
257+
> at the same level of discovered `.cargo/config.toml` in your porject.
258+
> For instance, given a project `/my/project`,
259+
> it is recommended to put config files under `/my/project/.cargo`
260+
> or a new directory at the same level, such as `/my/project/.config`.
248261
249262
```toml
250263
# Relative path examples.

0 commit comments

Comments
 (0)