27 releases
0.3.0 | Jan 8, 2023 |
---|---|
0.2.9 | Nov 21, 2022 |
0.2.8 | Oct 30, 2022 |
0.2.3 | Jul 24, 2022 |
0.1.7 | Jun 6, 2020 |
#767 in Command line utilities
190 downloads per month
22KB
510 lines
cargo-patch
Cargo-Patch
is a Cargo Subcommand which allows
patching dependencies using patch files.
Installation
Simply run:
cargo install cargo-patch
Usage
To patch a dependency one has to add the following
to Cargo.toml
:
[package.metadata.patch.serde]
version = "1.0"
patches = [
"test.patch"
]
It specifies which dependency to patch (in this case serde) and one or more patchfiles to apply. Running:
cargo patch
will download the serde package specified in the
dependency section to the target/patch
folder
and apply the given patches. To use the patched
version one has to override the dependency using
replace
like this
[patch.crates-io]
serde = { path = './target/patch/serde-1.0.110' }
Patch format
You can either use diff or git to create patch files. Important is that file paths are relative and inside the dependency.
Using diff file generated by GitHub pull request
[package.metadata.patch.serde]
version = "1.0"
patches = [
{ path = "generatedByGithub.patch", source = "GithubPrDiff" },
{ path = "generatedByGithub2.patch", source = "GithubPrDiff" },
"test.patch",
"test2.patch"
]
Limitations
It's only possible to patch dependencies of binary crates as it is not possible for a subcommand to intercept the build process.
Dependencies
~47MB
~1M SLoC