Error Message Regarding rust-analyzer starting in root dir

I'm getting the following error message when I start up VS Code on an existing project. What's it doing looking in the root directory, of all places?

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:

rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file c:\Cargo.toml, Some(Version { major: 1, minor: 68, patch: 2 }): Failed to run "cargo" "metadata" "--format-version" "1" "--manifest-path" "c:\\Cargo.toml" "--filter-platform" "x86_64-pc-windows-msvc": cargo metadata exited with an error: error: manifest path c:\Cargo.toml does not exist

Oh, and how do I fix the problem? I tried uninstalling and reinstalling the rust-analyzer extension, shutting down and restarting the machine, etc.


The default way to see if you're a workspace member is to just walk up parent directories looking for a Cargo.toml that defines a workspace.

Not sure why you're getting the error though.

  • SOLVED *

Somehow the 'settings.json' file in the project was created and contained a reference to the root directory. Removing that file solved the problem.

Only that one project experienced the problem.


I think this might be a rust-analyzer bug, because the feature that makes that settings change is new, and I remember someone else having the same problem, so I reported it.

To clarify the somehow in the created part, there is a bug where when you click the No option for the project linking popup it will add the entry.

Had this problem as well. Thanks!

Vs code suggested adding cargo.toml to workspace autmatically and just clicked okay. And then it made the settings.json that made it bug.

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.