如何修复我的 Cargo 文件中不匹配的依赖项以解决本机库冲突?

How do I fix mismatching dependencies in my Cargo file to work around native library collisions?

我正在使用 Rocket and I'm trying to use it with a JWT library 设置 Rust 服务器。他们使用不同版本的 *ring* crate,我在 cargo build:

期间收到错误消息
error: multiple packages link to native library `ring-asm`, but a native library can be linked only once

package `ring v0.12.1`
    ... which is depended on by `jsonwebtoken v4.0.1`
    ... which is depended on by `auther v0.1.0 (file:///home/drpytho/x/downloadble/auther)`
links to native library `ring-asm`

package `ring v0.11.0`
    ... which is depended on by `cookie v0.9.2`
    ... which is depended on by `rocket v0.3.6`
    ... which is depended on by `rocket_codegen v0.3.6`
    ... which is depended on by `auther v0.1.0 (file:///home/drpytho/x/downloadble/auther)`
also links to native library `ring-asm`

我的Cargo.toml

[package]
name = "auther"
version = "0.1.0"
authors = ["Name <Email@mail.se>"]

[dependencies]
rocket = "0.3.6"
rocket_codegen = "0.3.6"
jsonwebtoken = "4"
serde_derive = "1"
serde = "1"

我了解到您应该修复 Cargo 文件中不匹配的依赖项,但我不知道该怎么做。

您必须通过不依赖于 link 到本机库的不同版本的板条箱来解决此问题。

没有更新版本的 rocket 取决于 cookie0.10 版本,后者取决于 ring 0.12,因此您将需要将 jsonwebtoken 降级为 2.0.3

您可以通过检查 crates.io 页面中有问题的板条箱(例如 jsonwebtoken)来解决这个问题,返回旧版本,并查看它需要什么依赖项。