rust编译项目时遇到问题:

error: package `lock_api v0.4.14` cannot be built because it requires rustc 1.71.0 or newer, while the currently active rustc version is 1.58.0-nightly

原因是rust版本低,正常情况下会考虑升高rust版本。

但只是一个包的依赖问题就提高rust版本可能会出现一系列其他的连锁问题,如这里遇到的:

error: error loading target specification: abi-blacklist: unknown field `abi-blacklist`, expected one of...

首先考虑指定在cargo.toml中指定lock_api版本:

[patch.crates-io]
lock_api = { version = "=0.4.9", package = "lock_api" }

但是依旧报错:

Caused by:
  patch for `lock_api` in `https://github.com/rust-lang/crates.io-index` points to the same source, but patches must point to different sources

懒得管这些问题了,直接修改cargo.lock,指定版本:

cargo update -p lock_api --precise 0.4.9

修改后编译通过

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐