Rust-analyzer failed to read Cargo metadata

Everything was fine until I just updated to rust 1.53 and upgraded VSCode. When VSCode started, the latest version of rust-analyzer (0.2.646) installed. Now I'm getting the error in the title in 2 of my 3 workspaces.

In the past the cause was an error in Cargo.toml. Unlike other times I've run into this problem, the error message is not particularly informative. It simply says, "cargo metadata exited with an error."

Here's the smaller failing Cargo.toml.

name = "my_package"
version = "0.1.0"
authors = ["xxxxxxxxx <>"]
edition = "2018"

actix-files = "0.1.4"
actix-web = "2.0"
actix-rt = "1.0"
failure = "0.1.5"
serde = { version = "1.0.27", features = ["rc"] }
serde_derive = "1.0.27"
serde_json = "1.0.9"
1 Like

Try running

cargo metadata

in your project directory. It will tell you what it doesn't like. If it happens to work when you run it, then unfortunately it's some environment configuration issue with the editor integration.

cargo metadata spit out a ton of text, but it appears to have worked. Since the problem started after an update of Rust, VSCode, and Rust Analyzer, I expect it's a problem that will be fixed in a newer version of one of the three.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.