rust-analyzer: Failed to read Cargo metadata from rustc source

I am working on the Rust compiler and was trying to set up the compiler, but rust-analyzer decided to stop working for some reason. I followed the rust dev guide and I do have a settings.json file in .vscode.

This is the error message: [ERROR project_model::workspace] Failed to read Cargo metadata from rustc source at /home/Aryan/Documents/projects/rust/./Cargo.toml e=Failed to run `"/home/Aryan/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/Aryan/Documents/projects/rust/./Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"`

I also have cargo in PATH: ❯ echo $PATH /home/Aryan/eww/target/release:/home/Aryan/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/home/Aryan/.spicetify:/home/Aryan/pipes.sh

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Gotcha. I will do that and post the solution here in case someone runs into the same issue. Thanks for your help and time!

Well, I just added it, restarted Code, but still the same issue.

rust-toolchain.toml

[toolchain]
channel="nightly"

info: note that the toolchain ‘stable-x86_64-unknown-linux-gnu’ is currently in use (directory override for ‘/home/Aryan/Documents/projects/rust’)