无法指定 `edition2021` 以使用 Rust 中的不稳定包

43

我想通过Cargo运行一个示例,但是遇到了错误:

error: failed to parse manifest at `/Users/aviralsrivastava/dev/subxt/Cargo.toml`

完整的堆栈跟踪信息为:

error: failed to parse manifest at `/Users/aviralsrivastava/dev/subxt/Cargo.toml`

Caused by:
  feature `edition2021` is required

  The package requires the Cargo feature called `edition2021`, but that feature is not stabilized in this version of Cargo (1.56.0-nightly (b51439fd8 2021-08-09)).
  Consider adding `cargo-features = ["edition2021"]` to the top of Cargo.toml (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2021 for more information about the status of this feature.

根据建议,我继续修改Cargo.toml:

  Consider adding `cargo-features = ["edition2021"]` to the top of Cargo.toml (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
diff --git a/Cargo.toml b/Cargo.toml
index 26a02c7..186d09b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [workspace]
 members = [".", "cli", "codegen", "macro"]
-
+cargo-features = ["edition2021"]
 [package]
 name = "subxt"
 version = "0.15.0"
(END)

即使在toml文件中没有改变任何内容,我仍然面临相同的错误。

如何解决上述错误以使用不稳定的软件包?


1
降级工具链怎么样? - AurevoirXavier
1
Try nightly-2021-04-22. - AurevoirXavier
没有成功。同样的错误。https://pastebin.com/rtxZdtLi - Aviral Srivastava
那么 rustup default nightly && rustup update 呢? 我克隆了 subxt 存储库,对我来说运行良好。 - AurevoirXavier
1
哈哈,@ShawnTabrizi先生,我已经做了。几天前在Discord上看到这个词时就已经做了。我也会在我的圈子里传播它。 - Aviral Srivastava
显示剩余5条评论
5个回答

58

更新Rust以满足新版2021的要求。

rustup default nightly && rustup update

感谢@ken。 是的,您也可以使用stable渠道!

但我个人喜欢nightly


2
今天早上我在使用我的英特尔 Mac 时遇到了这个问题,只需在稳定分支上运行 rustup update 就足够了...在我的 M1 Mac 上整个周末一直使用 2021 版本没有问题,但可能是运行了更新版本。无论如何,2021 现在是一个稳定的发布版本。 - ken

17

2021版现在已经成为了 稳定版本 的一部分。

和我的情况一样,您可能只需要通过运行 rustup update stable 来更新您的稳定版本。

这应该可以解决问题,而无需切换到每夜版本。


2
这应该是现在的最佳答案! - Ben Usman

5

请尝试:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env && rustup default nightly && rustup update

这对我起作用了。 - KhoPhi

0

一些机器(包括搭载 M1 芯片的机器)可能无法构建


0

在使用Solana时,遇到了这个错误两次。如果Solana不是最新版本,则可能会出现此错误。请使用以下命令更新:sh -c "$(curl -sSfL https://release.solana.com/v1.10.26/install)"

或者更好的方法是在此处查找最新版本和安装说明https://docs.solana.com/cli/install-solana-cli-tools


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接