如何具有相同间接依赖项的多个不兼容版本?

时间:2019-12-18 20:43:56

标签: rust rust-cargo

我正在尝试在同一项目中使用actix-webreqwest板条箱,但它们依赖于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的测试移到单独的程序包中

0 个答案:

没有答案