rust-analyzer: FetchWorkspaceError

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: cd "/foo/scratch" && "cargo" "--version" failed: No such file or directory (os error 2)

I have a workspace that has a bunch of crates in it now and for some reason it fails on this particular one. If I cd into each separate crate in the workspace and call vscode on that then rust-analyzer works fine. It seems that running it from the root of the workspace is causing issues.

rust-analyzer version: 0.3.1459-standalone

rustc version: rustc 1.70.0-nightly (2036fdd24 2023-03-27)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

cargo 1.70.0-nightly (145219a9f 2023-03-27)
rustc 1.70.0-nightly (2036fdd24 2023-03-27)
vscode 1.77.0

About this issue

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

Most upvoted comments

@MaxGraey There is a bug where when you click the No option for the project linking popup it will add the entry, check your workspace’s settings.json and remove the linkedProjects setting

removing linkedProjects from settings.json fixed it for me.

I’d just like to point out that if anyone else is struggling to find the culprit behind this error, it may be located either of the settings.json files (workspace, default, remote, user).

I found mine in my user settings:

        "settings": {
                "rust-analyzer.linkedProjects": [
                        "./foo/feefoo"
                ]
        }

@Veykril Thanks! I thought I had removed any references to linkedProjects that might have accidentally appeared in settings.json. It turned out that this entry was in the workspace section, not globally. So there really was /Cargo.toml. Now everything works

I found this in one of my *.code-workspace files and not in the settings.json.

        "settings": {
                "rust-analyzer.linkedProjects": [
                        "./crates/abc"
                ]
        }

that’s the answer for me

I found this in one of my *.code-workspace files and not in the settings.json.

        "settings": {
                "rust-analyzer.linkedProjects": [
                        "./crates/abc"
                ]
        }

@MaxGraey There is a bug where when you click the No option for the project linking popup it will add the entry, check your workspace’s settings.json and remove the linkedProjects setting

This one works for me. Thanks a lot.

@MaxGraey There is a bug where when you click the No option for the project linking popup it will add the entry, check your workspace’s settings.json and remove the linkedProjects setting

This seemed to help but only after I restarted vscode. Unfortunately one of my repositories still can’t get it working. Same error message.

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: cd "/runtime" && "cargo" "--version" failed: No such file or directory (os error 2)