rust-analyzer failed to discover workspace in vscode

I guess you don’t have a Cargo.toml file in your project? The rust-analyzer needs a Cargo.toml to detect the workspace.

You could create a new rust project with cargo:

cargo new your-project

cargo will help you create a Cargo.toml file automatically, or you could manually create a Cargo.toml for your existing project.

If this issue keep popping up, perhaps you could check this Github issue for help.

Edit:

You should open your project like this, instead of opening the parent directory of guessing_game. Just try the following steps:

  1. cargo new guessing_game_v2;
  2. then in VSCode, Choose “File” -> “Open Folder..” -> Choose the new guessing_game_v2 folder
  3. and check if it works?

enter image description here

You should make sure that your Cargo.toml is in the root of workspace.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)