8

I have a clean project to which I include anyhow 1.0.66. Installed the latest version of rust. I'm getting an error saying that anyhow requires a nightly version. Perhaps this is due to the use of backtrace, but it is supported in rust version 1.65. I don't understand how to solve the problem.

Cargo.toml

[package]
name = "libfs"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio = {version = "1.22", features = ["full"]}
anyhow = {version = "1.0.66", features = ["default"]}

src/lib.rs

#[tokio::test]
async fn run_test() {
    println!("test");
}

output

$ cargo build
   Compiling anyhow v1.0.66
error[E0554]: `#![feature]` may not be used on the stable release channel
   --> /home/dima/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.66/src/lib.rs:214:32
    |
214 | #![cfg_attr(backtrace, feature(error_generic_member_access, provide_any))]
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
   --> /home/dima/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.66/src/lib.rs:214:61
    |
214 | #![cfg_attr(backtrace, feature(error_generic_member_access, provide_any))]
    |                                                             ^^^^^^^^^^^

For more information about this error, try `rustc --explain E0554`.
error: could not compile `anyhow` due to 2 previous errors

Genius Merely
  • 374
  • 2
  • 11
  • Some backtrace APIs are now stabilized in the standard library as of 1.65, yes. That does not mean that `anyhow`'s backtrace feature no longer require nightly. The now-stable APIs may not be sufficient for `anyhow`'s backtrace feature. I recommend following this issue: https://github.com/dtolnay/anyhow/issues/284 – PitaJ Nov 21 '22 at 21:05

1 Answers1

14

The problem was solved by:

rm -rf target
cargo check

This seems to be related to dtolnay/anyhow/issues/250 and rust-lang/rust-analyzer/issues/12973.

Sven Marnach
  • 574,206
  • 118
  • 941
  • 841
Genius Merely
  • 374
  • 2
  • 11