williamboman / nvim-lsp-installer

Further development has moved to https://github.com/williamboman/mason.nvim!
https://github.com/williamboman/mason.nvim
Apache License 2.0
2k stars 123 forks source link

`terraform-ls` Unable to find executable. Please check your path and ensure the server is installed #561

Closed fillipe-gsm closed 2 years ago

fillipe-gsm commented 2 years ago

Problem description

I installed the terraform language server with the usual LspInstall terraformls. The installation succeeds. However, when I open any file with the .tf extension I get no autocomplete.

When checking for LspInfo, I see the "Unable to find executable. Please check your path and ensure the server is installed".

I tried uninstalling and installing it again, updating the plugin, and even renaming the executable file, with no luck.

If I go to my $HOME/.local/share/nvim/lsp_servers/terraform path I see the following structure:

.
├── nvim-lsp-installer-receipt.json
└── terraform-ls
    └── terraform-ls

I know I can run the executable with ./terraform-ls serve, so there may be some configuration I am not aware.

Neovim version (>= 0.6)

NVIM v0.6.1 Build type: Release LuaJIT 2.1.0-beta3 Compiled by builduser

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Operating system/version

Linux fillipe-loggi 5.15.28-1-MANJARO #1 SMP PREEMPT Fri Mar 11 14:12:57 UTC 2022 x86_64 GNU/Linux

I've recently downloaded the latest plugin version of both nvim-lsp-installer and nvim-lspconfig

Affected language servers

terraform-ls

Steps to reproduce

  1. Start neovim with the pertaining `lsp-installar' config:
    
    local lsp_installer = require "nvim-lsp-installer"

-- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches lsp_installer.on_server_ready(function(server) -- Specify the default options which we'll use to setup all servers local opts = { on_attach = on_attach, capabilities = capabilities, flags = { -- This will be the default in neovim 0.7+ debounce_text_changes = 150, }, }

server:setup(opts)

end)

2. Open any file with the `.tf` format
3. Install `terraform-ls` with `:LspInstall terraformls`
4. Close and open it again. Server is not found.

### Actual behavior

Server do not start.

### Expected behavior

Server should start.

### LspInfo

```shell
Language client log: /home/fillipe/.cache/nvim/lsp.log
 Detected filetype:   terraform

 0 client(s) attached to this buffer: 

 Other clients that match the filetype: terraform

 Config: terraformls
    filetypes:         terraform
    root directory:    NA
    cmd:               terraform-ls serve
    cmd is executable: Unable to find executable. Please check your path and ensure the server is installed
    autostart:         true
    custom handlers:   

 Configured servers list: r_language_server, terraformls, sumneko_lua, jedi_language_server, emmet_ls

Healthcheck

nvim-lsp-installer: require("nvim-lsp-installer.health").check()
========================================================================
## nvim-lsp-installer report
  - OK: neovim version >= 0.6.0
  - WARNING: **Go**: not available
  - WARNING: **Ruby**: not available
  - WARNING: **RubyGem**: not available
  - WARNING: **Composer**: not available
  - WARNING: **PHP**: not available
  - WARNING: **julia**: not available
  - OK: **tar**: `tar (GNU tar) 1.34`
  - OK: **gzip**: `gzip 1.11`
  - OK: **curl**: `curl 7.82.0 (x86_64-pc-linux-gnu) libcurl/7.82.0 OpenSSL/1.1.1m zlib/1.2.11 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.2 libpsl/0.21.1 (+libidn2/2.3.0) libssh2/1.10.0 nghttp2/1.47.0`
  - OK: **wget**: `GNU Wget 1.21.2 built on linux-gnu.`
  - OK: **python3**: `Python 3.10.2`
  - OK: **node**: `v16.13.2`
  - OK: **bash**: `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)`
  - OK: **sh**: `Ok`
  - OK: **java**: `Ok`
  - OK: **javac**: `javac 17.0.3`
  - OK: **npm**: `8.5.4`
  - OK: **pip3**: `pip 21.0 from /usr/lib/python3.10/site-packages/pip (python 3.10)`

Screenshots or recordings

No response

williamboman commented 2 years ago

Hello! It seems like lspconfig is unable to find a root directory (:h lspconfig-root-dir). The root dir pattern for terraformls happens to be .terraform, .git. Have you tried editing a terraform file inside a git repository?

fillipe-gsm commented 2 years ago

Hi, sorry for the late reply!

I was actually following the Quickstart tutorial from HashiCorp, so there was no git repository.

I ended up finishing the code with no autocomplete and run terraform init. After that, when I opened the file again, the server was properly running! It seems it really needs a .terraform folder created from 'terraform init`.

I tried creating other projects. I noticed that simply running terraform init on an empty configuration file is not enough for the server to start. I had to write a minimal configuration first, run terraform init, and then the autocomplete begins to work.

I am not sure I am just convoluting the whole process, but it seems there is no issue with the plugin.

Thanks for the reply!

mvaldes14 commented 2 years ago

Had the exact same issue, ended up copying the terraformls binary to my path, also had to do this for stylua.

I do have both .git and .terraform in my project and no dice until I copied that file over.

Another thing and it's completely unrelated is that the official hashicorp lsp server is quite poor in features so i grabbed the alternative, renamed it to match what lsp installer has configured and now I get completions and overall a better experience. Should that server be also added to the list?

williamboman commented 2 years ago

Hey @mvaldes14 try pulling the latest version, this should've been fixed in #630!

mvaldes14 commented 2 years ago

Excellent, yep that fixes the problem. thank you very much @williamboman !