我正在尝试在同一项目中使用actix-web
和reqwest
板条箱,但它们依赖于tokio
的不同版本。
显然,Cargo无法选择满足所有直接依赖关系的tokio
版本,但我什至没有在相同的上下文中使用这些依赖关系:
actix-web
用于服务器REST API实现reqwest
仅用于系统测试Cargo.toml:
[package]
name = "test-cargo"
version = "0.1.0"
edition = "2018"
[dependencies]
actix-rt = "1.0.0"
actix-web = "2.0.0-alpha.6"
[dev-dependencies]
reqwest = "0.10.0-alpha.2"
cargo build
的输出:
Updating crates.io index
error: failed to select a version for `tokio`.
... required by package `reqwest v0.10.0-alpha.2`
... which is depended on by `test-cargo v0.1.0 (/workspaces/test-cargo)`
versions that meet the requirements `= 0.2.0-alpha.6` are: 0.2.0-alpha.6
all possible versions conflict with previously selected packages.
previously selected package `tokio v0.2.4`
... which is depended on by `actix-rt v1.0.0`
... which is depended on by `actix-web v2.0.0-alpha.6`
... which is depended on by `test-cargo v0.1.0 (/workspaces/test-cargo)`
failed to select a version for `tokio` which could resolve this conflict
我已经想到了一些解决方法,但是它们都不可接受:
tokio
版本-那么我的依赖项不是我想要的版本。 reqwest
的类似板条箱替换tokio
,然后我的依赖项不是我想要的板条箱。 reqwest
的测试移到单独的程序包中