< 返回版块

1148118271 发表于 2021-06-17 14:37

Tags:crate 依赖

├── bitarray v0.3.0
│   ├── cfg-if v1.0.0
│   └── space v0.11.0
└── cv v0.6.0
    ├── akaze v0.7.0
    │   ├── bitarray v0.2.6
    │   │   └── cfg-if v0.1.10
    │   ├── cv-core v0.15.0
    │   │   ├── derive_more v0.99.14 (proc-macro)
    │   │   │   ├── convert_case v0.4.0
    │   │   │   ├── proc-macro2 v1.0.27
    │   │   │   │   └── unicode-xid v0.2.2
    │   │   │   ├── quote v1.0.9
    │   │   │   │   └── proc-macro2 v1.0.27 (*)
    │   │   │   └── syn v1.0.73
    │   │   │       ├── proc-macro2 v1.0.27 (*)
    │   │   │       ├── quote v1.0.9 (*)
    │   │   │       └── unicode-xid v0.2.2
    │   │   ├── nalgebra v0.21.1


有两个依赖库,都依赖了 bitarray, 一个是 bitarray v0.3.0, 另一个是 bitarray v0.2.6, 如何让它两个都依赖 bitarray v0.3.0, 去除掉0.2.6版本的那个依赖

评论区

写评论
Mike Tang 2021-06-17 20:54

放的位置不对?

要放在使用树的root层,这样会替换掉树下所有分支的那个 crate_name 版本。

作者 1148118271 2021-06-17 17:38
[patch.crates-io]
bitarray = { path = "bitarray", features = [ "serde" ]}

用了patch.crates-io之后没有啥改变, 还是会引之前的依赖.

build的时候会有下面的警告:

warning: Patch `bitarray v0.3.0 (/Users/xxx/xx/bitarray)` 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.

--
👇
LuoZijun: Replacing dependencies with patch

https://doc.rust-lang.org/edition-guide/rust-2018/cargo-and-crates-io/replacing-dependencies-with-patch.html

LuoZijun 2021-06-17 15:16

Replacing dependencies with patch

https://doc.rust-lang.org/edition-guide/rust-2018/cargo-and-crates-io/replacing-dependencies-with-patch.html

1 共 3 条评论, 1 页