zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
46.56k stars 2.64k forks source link

Terraform LSP failed to init #14502

Closed Moshyfawn closed 1 month ago

Moshyfawn commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

The TF LSP fails to initialise when opening a .tf file both with and without TF in the PATH.

Environment

Zed: v0.145.0 (Zed Nightly e8d674dc04fdd3f74946014ef92e76fd9b78ba9c) OS: macOS 14.5.0 Memory: 18 GiB Architecture: aarch64

Terraform: v0.0.3

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log

[INFO] retrying installation of language server "terraform-ls" in 1s
[INFO] About to spawn test binary
[WARN] test binary failed to launch
[WARN] test binary check failed
[INFO] beginning to reinstall server
[INFO] deleting server container
[ERROR] server container removal

Caused by:
    No such file or directory (os error 2)
[INFO] starting language server "terraform-ls", path: "//", id: 6
[INFO] starting language server. binary path: "//Library/Application Support/Zed/extensions/work/terraform/terraform-ls-v0.34.0/terraform-ls", working directory: "//", args: ["serve"]
[ERROR] failed to start language server "terraform-ls": failed to spawn command. path: "//Library/Application Support/Zed/extensions/work/terraform/terraform-ls-v0.34.0/terraform-ls", working directory: "//", args: ["serve"]
[ERROR] server stderr: Some("")
[ERROR] Hit 4 reinstallation attempts for "terraform-ls"
dbanck commented 1 month ago

I'm seeing the same problem on Zed Preview (0.144.3), it's working for stable (Zed 0.143.7).

It looks like the binary in ~/Library/Application\ Support/Zed/extensions/work/terraform is missing the executable flag:

❯ ls -lha terraform-ls-v0.34.0/terraform-ls
-rw-r--r--  1 daniel.banck  staff    27M Jul 17 11:30 terraform-ls-v0.34.0/terraform-ls 

A temporary workaround is to set the flag manually: chmod +x terraform-ls-v0.34.0/terraform-ls

The source zip file for the language server contains the binary with the flag set, so I my first guess is that it is removed during installation.

taleh007 commented 1 month ago

Looks like Zed 0.144.4 is affected too.

> ls -lah ~/Library/Application\ Support/Zed/extensions/work/terraform/terraform-ls-v0.34.1
total 56504
drwxr-xr-x  4 user  staff   128B Jul 24 12:44 .
drwxr-xr-x  8 user  staff   256B Jul 24 12:44 ..
-rw-r--r--  1 user  staff    16K Jul 24 12:44 LICENSE.txt
-rw-r--r--  1 user  staff    27M Jul 24 12:44 terraform-ls

UPD: Looks like https://releases.hashicorp.com/terraform-ls/0.34.1/ provide files with +x for my platform

Zed: 0.144.4 (Zed https://github.com/zed-industries/zed/commit/5686e103316a721add738f3526f20802879e9970) OS: macOS 14.5.0 Memory: 36 GiB Architecture: aarch64

maxdeviant commented 1 month ago

v0.0.4 of the Terraform will now mark the downloaded language server binary as executable, which should fix this issue.

Note that if you already have the latest language server version downloaded you'll need to delete the containing directory so that it gets downloaded again. On macOS the directory is ~/Library/Application\ Support/Zed/extensions/work/terraform.

dbanck commented 1 month ago

Thank you! That fixes the issue for me

taleh007 commented 1 month ago

Thanks for your work!