【问题标题】:Unable to specify `edition2021` in order to use unstable packages in Rust无法指定 `edition2021` 以在 Rust 中使用不稳定的包
【发布时间】:2021-11-05 03:15:47
【问题描述】:

我想通过 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 文件中没有任何更改。

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

【问题讨论】:

  • 降级你的工具链怎么样?
  • 这是什么意思?对不起,我是新来的。你是说subxt降级还是subxt节点?
  • 你的 rust 版本。
  • 尝试 nightly-2021-04-22。
  • 哈哈@ShawnTabrizi 先生,我已经做到了。几天前,当我在 Discord 中看到这个词时。也会在我的圈子里流传。

标签: rust substrate polkadot


【解决方案1】:

更新 Rust 以满足新版本 2021。

rustup default nightly && rustup update

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

但我个人喜欢nightly

【讨论】:

  • 我今天早上使用我的英特尔 Mac 遇到了这个问题,并在稳定的分支上运行了 rustup update,这就足够了......整个周末我的 M1 Mac 上一直使用 2021 版没有问题问题,但也许它正在运行更新版本。无论如何,2021 年现在是一个稳定版本。
  • 在任一频道上都不起作用。同样的错误
  • 我必须更新 Solana 然后它才能工作sh -c "$(curl -sSfL https://release.solana.com/v1.9.13/install)"
【解决方案2】:

试试:

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

【讨论】:

  • 这对我有用
【解决方案3】:

2021 版现在是 stable channel 的一部分。

正如我所发生的那样,您可能只需要通过运行rustup update stable 来更新您的稳定版本。

这应该可以解决问题,并且不需要您切换到夜间频道。

【讨论】:

    猜你喜欢
    • 2022-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-31
    • 2016-01-14
    • 2017-12-31
    • 2022-01-17
    相关资源
    最近更新 更多