我正在尝试修复 Rust/Cargo 中的依赖问题。我有一个依赖项
ctclib-pp
,而它又依赖于bindgen 0.59.2
。但是,出于兼容性原因,我需要使用 0.60.1 或更高版本的 bindgen(因为this)。
我在 Cargo.toml 中尝试了以下更改,但这似乎不起作用,因为这似乎将两个版本安装在彼此旁边。
[dependencies]
ctclib-pp = "0.2.0"
[patch.crates-io]
bindgen = { git = "https://github.com/rust-lang/rust-bindgen", tag = "v0.60.1" }
当我运行
cargo update
时,我收到以下通知:
warning: Patch `bindgen v0.60.1 (https://github.com/rust-lang/rust-bindgen?tag=v0.60.1#9ca5f856)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
并且锁定文件现在包含未使用的补丁
[[patch.unused]]
name = "bindgen"
version = "0.60.1"
source = "git+https://github.com/rust-lang/rust-bindgen?tag=v0.60.1#9ca5f856a35deddde0575002d76d1db4430e6c42"
关于如何覆盖子依赖项有什么建议吗?
您需要修补
bindgen
的依赖项,即 ctclib-pp
。复制它,然后(假设所有内容都可以通过此修改进行编译)修改它所依赖的 bindgen
的版本。然后,在您的 [patch.crates-io]
中指定它。