I've been having a really great experience w/ eglot for C++ development. I'm finding it a lot easier to use than lsp-mode (at least for C++). However, I'm running into an issue w/ both eglot (and lsp-mode, actually). M-x eglot when opening a rust source file gives:

[eglot] Server reports (type=1): Failed to discover workspace.
Consider adding the `Cargo.toml` of the workspace to the [`linkedProjects`](https://rust-analyzer.github.io/manual.html#rust-analyzer.linkedProjects) setti\

Failed to load workspaces.

NB: lsp-mode gives a similar error

First, it's a new project that has a Cargo.toml right in the root:

(base) mmessersmith@HP-ZBK-0425:~/repos/ruster$ tree
├── Cargo.lock
├── Cargo.toml
├── README.md
└── src
    └── main.rs

It cannot be rocket science to go and find that Cargo.toml file, so it seems like a really odd failure. I didn't do anything crazy here: I created the project w/ cargo like a normal person.

Secondly, where the heck is the config file the error message alludes to (on Ubuntu)? I can't find it. The only place I could find it was in their source code, so I re-built the rust-analyzer bin from source but changed that linkedProjects directory to point right to my Cargo.toml (e.g. changed the default in source): still no luck. I also tried randomly putting a settings.json in ~/.vscode-server/extensions/settings.json`, also no luck.

How can I update such that I can get eglot to work with rust-analyzer?

I am open to amending this mysterious config, wherever it may reside, but best solution I am looking for is to be able to auto-find the Cargo.toml.

There is nothing relevant here in my .emacs, so I won't list it. I'm just calling M-x eglot manually for now, no rust-mode hooks, etc.

EDIT: Just created a new project and it seems to be working now. I will let this simmer though, in case someone else runs into this issue and there is a fix.

  • Im getting the same with Dart. And I cant pinpoint what I changed,
    – RichieHH
    Commented Aug 1, 2023 at 9:24
  • Have you found a solution? How to specify linkedProjects for eglot? Commented Oct 7, 2023 at 6:22


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.