When I try to use rust-analyzer with neovim, it complains that it 1) can find any projects in my home directory, despite the fact that the wd is not the home directory 2) It can't find the workspace.
:LspInfo shows the root directory to be correct.
I am using the default rust_analyzer lsp config i.e vim.enable
I have the newest rust-analyzer (1.9)
- Can you include the exact error so that we can search and / or test ?
- And the full
rustup --version(which includes the activerustcas well. - And what is in your directory in terms of files? Just list the top level removing anything sensitive or obviously irrelevant. It's to check for
Config.tomlwith the right name, etc. although this may not matter, I can't remember now.
This is from the :LspLog
[ERROR][2025-10-19 17:52:41] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151 "rpc" "rust-analyzer" "stderr" '2025-10-19T17:52:41.54838222+03:00 ERROR failed to find any projects in [AbsPathBuf("/home/****")]\n'
[ERROR][2025-10-19 17:52:41] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151 "rpc" "rust-analyzer" "stderr" "2025-10-19T17:52:41.573717129+03:00 ERROR FetchWorkspaceError: rust-analyzer failed to fetch workspace\n"
[ERROR][2025-10-19 17:52:41] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151 "rpc" "rust-analyzer" "stderr" "2025-10-19T17:52:41.674354903+03:00 ERROR FetchWorkspaceError: rust-analyzer failed to fetch workspace\n"
[
rustup --version
rustup 1.28.2 (e4f3ad6f8 2025-04-28)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active rustc version is `rustc 1.90.0 (1159e78c4 2025-09-14)
The directory structure:
-- [project-dir] (also the working directory)
---- Cargo.lock
---- Cargo.toml
---- src/
---- target/
Thank you!
Are you opening your project from the project folder? Oh, you said so, sorry.
I think it is not necessarily neovim, because it appears in other editors; for example https://stackoverflow.com/questions/72062935/rust-analyzer-failed-to-discover-workspace-in-vscode
Also, could you surround all code or logs by backticks as in:
code here
If you create a pilot project with cargo new the_name does it fail as well?
I see. None of their solutions seem to be applicable to my situation unfortunately.
Will do. I have not used this platform before, so I am figuring things out now.
I get the same error. I forgot to mention that the HUD pops up as well with a message
error
ENOENT: no such file or directory
I am unsure what the error is; if no one saves you here you may try rust-lang/rust-analyzer ยท Discussions ยท GitHub (discussions or issue), although it you may be redirected somewhere else.
I am assuming you read this as well: Other Editors - rust-analyzer (the configuration guide.)
Yes, I looked at that. Thanks for trying, I'll take a look at the GitHub link.
I tried without lsp-config assuming you installed it. Since neovim has an LSP-client by default (but it is not that nice); so one really only needs the LSP-server (rust-analyzer)
This was "for fun" just to have an idea what is not the problem. It wont solve much, but may be worth tesing.
Running nvim -u my_test.lua -- src/main.rs only loads my_test.lua.
I wonder if such a minimal test would at least pass in your case. Here is mytest.lua
vim.lsp.config("ra", {
cmd = { "rust-analyzer" },
settings = {
["rust-analyzer"] = {
files = { watcher = "server" },
cargo = { targetDir = true },
check = { command = "clippy" },
inlayHints = {
bindingModeHints = { enabled = true },
closureCaptureHints = { enabled = true },
closureReturnTypeHints = { enable = "always" },
maxLength = 100,
},
rustc = { source = "discover" },
},
},
root_markers = { { "Config.toml" }, ".git" },
})
vim.lsp.enable("ra")
And then issue the command.
Well, I got no errors, but I am not sure where they would show up given that nothing that uses lsp was loaded.
You can just use that until the actual issue is solved, was my suggestion at least.
But yes it does not solve your question ![]()
(But to be clear errors should show in the files. If there are any. With a red E on a gutter to the left. And to check it loaded and is active use :checkhealth)
The configuration does show up as being active in :checkhealth. As far as errors, tgey showed up before as well, as long as they weren't related to protect structure, such as unused functions.
Thanks a lot for all the effort. I will keep poking at it.
ืืชืืจืื ืืื ืืณ, 19 ืืืืงืณ 2025, 23:55, ืืืช keyko via The Rust Programming Language Forum โ<notifications@rust-lang.discoursemail.com>:
You may also try here, some people know a lot https://matrix.to/#/#neovim:matrix.org
And it is active.
I'm curious, did you find a solution for your problem?
Thanks for asking. I have not managed to solve the issue. Even setting the root dir manually as suggested on the lspconfig github page didn't work, which is rather strange. I am going to try rustacean next, but my day job has been taking up all my time. ![]()
Have you tried the distribution LazyVim? It has an "extra" for rust which should do all the configuration.
IIRC, the only requirement is that the rust analyzer must be installed in the system, not through mason.
I have heard of the distro. I wanted to do my own config though :-(.
Just to update, rustaceanvim works in general, but also causes the same error to pop up in the HUD.
I was suggesting to try the distro. If it works, you can check how it configures rust support
Ah, got it. I can try that. thx