rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
52.69k stars 10.02k forks source link

error[E0658]: use of unstable library feature 'result_option_inspect' #2070

Closed vjsingh777 closed 1 month ago

vjsingh777 commented 1 month ago

Trying to install rustlings results in the error: .cargo/registry/src/index.crates.io-6f17d22bba15001f/rustlings-6.1.0/src/watch.rs:61:10 | 61 | .inspecterr(|| eprintln!("{NOTIFY_ERR}"))?; | ^^^^^^^^^^^

rustc 1.75.0 (82e1608df 2023-12-21) rustup 1.27.1 (54dd3d00f 2024-04-24)

mo8it commented 1 month ago

You get this error because you use an old version of Rust. Please install the latest version (Rust 1.80). You can do so by running rustup update (unless you installed Rust using a package manager on Linux. In that case, uninstall Rust and install it using the official method).

Sorry for the confusing error message. People will get a better error message in such situations starting with the next release.

vjsingh777 commented 1 month ago

Mo, i need to keep rust version at 1.75 due to solana and cargo library version clashes. Do you have any workarounds/solutions other than changing rust version ?

mo8it commented 1 month ago

rustup allows having multiple toolchains at the same time. So you can pin Rust 1.75 for some projects and use the latest stable version as a default for all others.

To pin a version for a project, you can use the following rust-toolchain.toml file:

[toolchain]
channel = "1.75.0"

If you want to keep 1.75 as the default, you can use an override for one command using +VERSION after cargo: cargo +1.80 install rustlings.

This might tell you that the toolchain for 1.80 isn't installed. You can then install it using rustup toolchain install 1.80.

Read more about overrides here: https://rust-lang.github.io/rustup/overrides.html

vjsingh777 commented 1 month ago

Fabulous! Thanks Mo for the education.