rust 错误:无法为`syn`选择版本

bq9c1y66  于 11个月前  发布在  其他
关注(0)|答案(4)|浏览(117)
error: failed to select a version for `syn`. \
    ... required by package `serde_derive v1.0.125`\
    ... which satisfies dependency `serde_derive = "=1.0.125"` of package `serde v1.0.125`    
    ... which satisfies dependency `serde = "^1.0.125"` of package `mongodb v2.1.0`\
    ... which satisfies dependency `mongodb = "^2.1"` of package `wagmeet v0.1.0 
 \(/mnt/e/College/Eighth Semester/Crypto_Capable/wagmeet_app)`\
versions that meet the requirements `^1.0.60` are: 1.0.86, 1.0.85, 1.0.84, 1.0.83, 1.0.82, 1.0.81, 1.0.80, 1.0.79, 1.0.78, 1.0.77, 1.0.76, 1.0.75, 1.0.74, 1.0.73, 1.0.72, 1.0.71, 1.0.70, 1.0.69, 1.0.68, 1.0.67, 1.0.66, 1.0.65, 1.0.64, 1.0.63, 1.0.62, 1.0.61, 1.0.60

all possible versions conflict with previously selected packages.

  previously selected package `syn v1.0.57`\
    ... which satisfies dependency `syn = "=1.0.57"` 
    \ of package `near-sdk-core v3.0.1`
    ... which satisfies dependency `near-sdk-core = "=3.0.1"` of package `near-sdk-macros v3.0.1` \
    ... which satisfies dependency `near-sdk-macros = "=3.0.1"` \ of package `near-sdk v3.0.1`   
    ... which satisfies dependency `near-sdk = "^3"` of package `wagmeet v0.1.0 `\

failed to select a version for `syn` which could resolve this conflict

字符串
Cargo.toml文件

[package]
name = "wagmeet"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["rlib","cdylib"]

[dependencies]
near-sdk = "^3.1.0"
near-contract-standards = "^3.1.1"
mongodb = "2.0.0"
bson = { version = "2", features = ["chrono-0_4"] } # Needed for using chrono datetime in doc
tokio = "1"
chrono = "0.4" # Used for setting DateTimes
serde = "1"
serde_derive = "1.0.135"

  • 更新添加了cargo.toml文件

我已经尝试了各种版本,现在似乎没有什么工作。mongoDb甚至兼容近协议?

wfveoks0

wfveoks01#

您的两个依赖项之间存在冲突:near-sdk需要 * 恰好 * syn版本1.0.57,而mongodb需要 * 至少 * syn版本1.0.60。显然两者不能共存。
你有几个解决方案:

  • 修补near-sdk以支持更高的syn版本。通常不建议这样做。
  • near-sdk升级到支持syn后续版本的预发行版4.0.0currently 4.0.0-pre.7)。这是一个不稳定的版本,可能会崩溃。
  • mongodb降级为支持syn版本1.0.57的版本。支持1.0.57的最新版本是1.2.5,因此您需要在Cargo.toml中指定mongodb = "=1.2.5"。但这依赖于旧的,不受支持的版本。

没有“最佳解决方案”。所有的解决方案都很糟糕。我可能会将near-sdk升级到4. 0. 0,但该怎么做取决于您的需要。

mccptt67

mccptt672#

当你在bin项目中使用依赖项时,它们会发生冲突,并将错误转储给你。
确保所有依赖项都指向相同的lib版本并运行cargo update

ht4b089n

ht4b089n3#

当我添加一个git依赖时,我得到了这个错误。

cargo update

字符串
解决了这个问题
更多信息:
我得到的错误是:

all possible versions conflict with previously selected packages.

  previously selected package `bytemuck v1.13.1`
    ... which satisfies dependency `bytemuck = "^1.7"` (locked to 1.13.1) of package `eframe v0.23.0`
    ... which satisfies dependency `eframe = "^0.23.0"` (locked to 0.23.0) of package `myproject v1.4.0 

failed to select a version for `bytemuck` which could resolve this conflict


然后货物更新导致:

Updating crates.io index
    Updating git repository `https://github.com/huggingface/candle.git`
    Updating ab_glyph v0.2.21 -> v0.2.23
    Updating accesskit v0.11.0 -> v0.11.2
    Updating accesskit_consumer v0.15.0 -> v0.15.2
    Updating accesskit_macos v0.7.1 -> v0.9.0
    Updating accesskit_unix v0.5.0 -> v0.5.2
    Updating accesskit_windows v0.14.0 -> v0.14.3
    Updating accesskit_winit v0.14.1 -> v0.14.4
      Adding addr2line v0.21.0
    ... and a whole lot more of Updating, Adding, and Removing.

llew8vvj

llew8vvj4#

尝试以下方法…

  • 检查修补后的依赖项是否指向正确的源存储库
  • 如果您使用其他项目Cargo.lock或更改某些依赖项,请删除目标文件夹并重新构建
  • 检查编译日志中不正确的依赖路径!
  • 更新Rust
  • 删除.cargo和.rustup目录

相关问题