Skip to content

Commit 622290e

Browse files
author
Jon Gjengset
committed
Document the patch-in-config feature
1 parent 695465c commit 622290e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/doc/src/reference/unstable.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,3 +1156,27 @@ absolute path.
11561156
TMPDIR = { value = "/home/tmp", force = true }
11571157
OPENSSL_DIR = { value = "vendor/openssl", relative = true }
11581158
```
1159+
1160+
### `[patch]` in .cargo/config.toml
1161+
* Original Pull Request: [#9204](https://github.com/rust-lang/cargo/pull/9204)
1162+
1163+
The `-Z patch-in-config` flag enables the use of `[patch]` sections in
1164+
cargo configuration files (`.cargo/config.toml`). The format of such
1165+
`[patch]` sections is identical to the one used in `Cargo.toml`.
1166+
1167+
Since `.cargo/config.toml` files are not usually checked into source
1168+
control, you should prefer patching using `Cargo.toml` where possible to
1169+
ensure that other developers can compile your crate in their own
1170+
environments. Patching through cargo configuration files is generally
1171+
only appropriate when the patch section is automatically generated by an
1172+
external build tool.
1173+
1174+
If a given dependency is patched both in a cargo configuration file and
1175+
a `Cargo.toml` file, the patch in `Cargo.toml` is used. If multiple
1176+
configuration files patch the same dependency, standard cargo
1177+
configuration merging is used, which prefers the value defined closest
1178+
to the current directory, with `$HOME/.cargo/config.toml` taking the
1179+
lowest precedence.
1180+
1181+
Relative `path` dependencies in such a `[patch]` section are resolved
1182+
relative to the configuration file they appear in.

0 commit comments

Comments
 (0)