43

I want to run an example via Cargo but I am facing an error:

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

The full stacktrace is:

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.

Based on the suggestion, I go ahead and modify the 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)

I still face the same error as if nothing was changed in the toml file.

How do I resolve the above error in order to use unstable packages?

Aviral Srivastava
  • 4,058
  • 8
  • 29
  • 81

5 Answers5

58

Update the Rust to satisfy the new edition 2021.

rustup default nightly && rustup update

Thanks to @ken. Yes, you can use the stable channel too!

But I love nightly personally.

AurevoirXavier
  • 2,543
  • 2
  • 17
  • 25
  • 2
    I ran into this issue this morning using my Intel Mac and just ran `rustup update` on the stable branch and that was enough ... had been using 2021 edition without issue on my M1 Mac all weekend without issue but maybe it was running the updated version. Anyway, 2021 is a stable release now. – ken Dec 13 '21 at 13:27
16

Edition 2021 is now part of the stable channel.

As what happened to me, you probably just need to update your stable version by running rustup update stable.

That should fix the issue, and not require you to switch over to the nightly channel.

chai_and_kaapi
  • 181
  • 1
  • 5
5

Try:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env && rustup default nightly && rustup update
Aviel Yosef
  • 533
  • 5
  • 10
0

Seen this error twice when working with Solana. You can get this error if Solana is not up to date. Update it with sh -c "$(curl -sSfL https://release.solana.com/v1.10.26/install)"

Or preferably find the latest version and instructions here https://docs.solana.com/cli/install-solana-cli-tools

Philip Rego
  • 552
  • 4
  • 20
  • 35
0

Some machines (including those with M1 chips) may be unable to build

zinderud
  • 27
  • 2