simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.16k stars 158 forks source link

Spawning language server with cmd: `rust-analyzer` failed. The language server is either not installed, missing from PATH, or not executable. #214

Closed gytis-ivaskevicius closed 2 years ago

gytis-ivaskevicius commented 2 years ago

I found a little edge case and I am not sure how to solve it.

Error:

Spawning language server with cmd: rust-analyzer failed. The language server is either not installed, missing from PATH, or not executable.

My setup: rust-analyzer is in fact NOT in path, BUT is being passed directly to lsp cmd attribute as path:

nvim_lsp.rust_analyzer.setup({
  cmd = [ '/path/to/rust-analzyer']
  ...
}
jrmoulton commented 2 years ago

I'm not sure how you have the rest of your configs but the problem might be that if you really are using rust-tools you need to pass the config into the rust-tools setup function.

local rust_opts = {
    server = {
        cmd = ['/path/to-rust-analyzer']
    },
}
require('rust-tools').setup(rust_opts)
gytis-ivaskevicius commented 2 years ago

Yep, this is exactly what I was looking for. Thanks!

simrat39 commented 2 years ago

Also please don't call lspconfig's setup, as rust-tools does it automatically and it causes conflicts if called twice