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
47.63k stars 2.79k forks source link

Elixir LS failing to download #6179

Closed nbernardes closed 1 year ago

nbernardes commented 1 year ago

Check for existing issues

Describe the bug / provide steps to reproduce it

When opening any project on Zed, I always get this error

Language server error: Elixir

no asset found matching "elixir-ls.zip"

elixir-ls works in VSCode, and I'm using elixir and erlang via asdf

> elixir -v
Erlang/OTP 25 [erts-13.2.2.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Elixir 1.14.5 (compiled with Erlang/OTP 25)

> asdf current
elixir          1.14.5-otp-25
erlang          25.3.2.2

Environment

Zed: v0.90.2 (stable) OS: macOS 13.4.0 Memory: 32 GiB Architecture: aarch64

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

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

...
2023-06-20T09:22:56 [INFO] starting language server name:elixir-ls, path:"/Users/bernardes/Developer/elixir/arcada", id:0
2023-06-20T09:22:57 [ERROR] crates/zed/src/languages/elixir.rs:105: no cached binary
2023-06-20T09:22:57 [ERROR] crates/project/src/project.rs:2455: no asset found matching "elixir-ls.zip"
2023-06-20T09:23:18 [ERROR] unexpected item event after pane was dropped
2023-06-20T09:24:21 [ERROR] crates/terminal_view/src/terminal_view.rs:264: view Terminal was dropped
2023-06-20T09:52:30 [ERROR] connection error: error reading rpc message from socket
...
mattbaker commented 1 year ago

asdf is maybe the most common way of installing and managing elixir versions in the elixir community, and I'm experiencing the same error. This bug will probably hit most elixir users.

Before I configured things in Zed I looked at the homebrew formula to make sure I was matching what it was doing. It makes sure the language server is compiled and that a symlink named elixir-ls points to the language server shell script, so I made sure I did the same and confirmed elixir-ls is in my path.

Not sure where elixir-ls.zip came into play, are more recent versions of the beta trying to download the elixir language server automatically without me having to install it globally? That would be nice, that's what vscode does and it would be a welcome improvement.

I'm excited that elixir-ls support is in progress though! It's the only thing standing between me and using Zed as my main editor :) Thanks for ya'lls efforts!

mattbaker commented 1 year ago

For the Zed folks: https://github.com/zed-industries/zed/issues/6178 looks like a duplicate

mattbaker commented 1 year ago

As a hacky short-term fix I was able to get this working I think. I ended up creating a symlink in ~/matt/Library/Application Support/Zed/languages/elixir-ls named elixir-ls that points to language_server.sh from the elixir-ls release directory.

So to summarize:

If anyone's installed elixir-ls a different way the same solution should work (I think), you just need to find where your elixir-ls release is so you can symlink to the language_server.sh file it contains.

❯ pwd
/Users/matt/Library/Application Support/Zed/languages/elixir-ls

❯ ln -s /Users/matt/code/elixir-ls/release/language_server.sh elixir-ls

I only tested jump to definition, find references, and that compile errors showed up in the file. I haven't actually done any significant coding yet so I can't say if surprises will crop up or not. Also confirmed I can view the elixir language server log output via the "open language server logs" command.

Hopefully this helps people get unblocked until the bug can be fixed! Excited to try out Zed full-time :)

nbernardes commented 1 year ago

asdf is maybe the most common way of installing and managing elixir versions in the elixir community, and I'm experiencing the same error. This bug will probably hit most elixir users.

Before I configured things in Zed I looked at the homebrew formula to make sure I was matching what it was doing. It makes sure the language server is compiled and that a symlink named elixir-ls points to the language server shell script, so I made sure I did the same and confirmed elixir-ls is in my path.

Not sure where elixir-ls.zip came into play, are more recent versions of the beta trying to download the elixir language server automatically without me having to install it globally? That would be nice, that's what vscode does and it would be a welcome improvement.

I'm excited that elixir-ls support is in progress though! It's the only thing standing between me and using Zed as my main editor :) Thanks for ya'lls efforts!

Feeling the same as you. I wanted to replace once in for all VSCode by Zed, but not having elixir-ls working correctly without to much of hacking around is a bummer.

Still, it's great to see that Elixir is talked on Zed docs, and hopefully it will be the best solution for Elixir development. I sometimes feel that VSCode is not 100% there.

nbernardes commented 1 year ago

As a hacky short-term fix I was able to get this working I think. I ended up creating a symlink in ~/matt/Library/Application Support/Zed/languages/elixir-ls named elixir-ls that points to language_server.sh from the elixir-ls release directory.

So to summarize:

  • I cloned the elixir-ls project
  • I compiled it and generated a release, which creates the release directory and the language_server.sh script
  • I created a symlink named elixir-ls in /Users/matt/Library/Application Support/Zed/languages/elixir-ls pointing to language_server.sh

If anyone's installed elixir-ls a different way the same solution should work (I think), you just need to find where your elixir-ls release is so you can symlink to the language_server.sh file it contains.

❯ pwd
/Users/matt/Library/Application Support/Zed/languages/elixir-ls

❯ ln -s /Users/matt/code/elixir-ls/release/language_server.sh elixir-ls

I only tested jump to definition, find references, and that compile errors showed up in the file. I haven't actually done any significant coding yet so I can't say if surprises will crop up or not. Also confirmed I can view the elixir language server log output via the "open language server logs" command.

Hopefully this helps people get unblocked until the bug can be fixed! Excited to try out Zed full-time :)

Unfortunately, this solution didn't worked for me. I've followed the steps you provided, but it didn't worked. @mattbaker I saw that you are on the Elixir Slack, if you can give me some sync assistance there I would be very much appreciated 🙂

benvp commented 1 year ago

I assume that the issue is caused by the recent change in the Release assets of ElixirLS on GitHub.

https://github.com/elixir-lsp/elixir-ls/releases/tag/v0.15.0

v0.15.0 is missing the asset elixir-ls.zip and now has the version number in the file name: elixir-ls-v0.15.0.zip.

In addition they changed the implementation to use Mix.install to make sure that the language server is compiled with the correct Erlang/Elixir combination to provide completions when using the use macro.

IMO zed should consider to start the launch.sh file instead of the language_server.sh file when starting up the language server. This ensures that the Erlang/Elixir version of asdf-vm is picked up when running the language server.

sergiotapia commented 1 year ago

Thank you gents @ Zed for taking a look at this. I'm also waiting for this to land before giving Zed two weeks of solid attention. I love your mission and I am keen to use Zed instead of VSCode.

mattbaker commented 1 year ago

For what it’s worth elixir-ls has been working in Zed perfectly with the workaround so far. I know @nbernardes wasn’t able to get it going (we’re not sure why) but I’d encourage you make an attempt if it means you get to start testing Zed a little sooner. Totally understand wanting to wait for a fix though, but I was impatient :)

moomerman commented 1 year ago

❤️ thanks @mattbaker, I just tried it and it works for me too, I've been without elixir-ls for 2 days and its been driving me crazy

fmmatheus commented 1 year ago

Confirming that the workaround provided by @mattbaker is working for me. Thanks dude 🙇

joebno commented 1 year ago

I've got the same issue with the elixir-ls not working, unfortunately the fix isn't working for me either 😢

jvelez1 commented 1 year ago

Just confirming that the workaround provided by @mattbaker is working for me. thank you 🙏🏻 I did an extra couple of things before the ln -s step

zimt28 commented 1 year ago

The fix worked for me after removing Zed from my system and installing the latest beta from the website. Adding

"lsp": {
  "Elixir": {}
}

to settings.json also seems to make a difference here, thanks @jvelez1 and @mattbaker 🥳

joebno commented 1 year ago

I finally managed to get it working - had to completely remove Zed and the Zed directory in ../Library/Application Support/, then re-install the latest beta.

Thanks @zimt28, @jvelez1 and @mattbaker 😺

Defman21 commented 1 year ago

IMO zed should consider to start the launch.sh file instead of the language_server.sh file when starting up the language server. This ensures that the Erlang/Elixir version of asdf-vm is picked up when running the language server.

@benvp language_server.sh runs launch.sh:

#!/bin/sh
# Launches the language server. This script must be in the same directory as mix install launch script.

readlink_f () {
  cd "$(dirname "$1")" > /dev/null || exit 1
  filename="$(basename "$1")"
  if [ -h "$filename" ]; then
    readlink_f "$(readlink "$filename")"
  else
    echo "$(pwd -P)/$filename"
  fi
}

if [ -z "${ELS_INSTALL_PREFIX}" ]; then
  dir="$(dirname "$(readlink_f "$0")")"
  >&2 echo "Running ${dir}/launch.sh"
else
  dir=${ELS_INSTALL_PREFIX}
  >&2 echo "ELS_INSTALL_PREFIX is set, running ${ELS_INSTALL_PREFIX}/launch.sh"
fi

export ELS_MODE=language_server
exec "${dir}/launch.sh"

And launch.sh tries to figure out which Erlang/Elixir version to use (asdf-vm or something else)

benvp commented 1 year ago

Oh, I misread that. Sorry!

Cervajz commented 1 year ago

Side note:

The reason why the workaround might not work for some of us is that currently elixir-ls is broken with OTP 26 - the server does not start at all.

It should be fixed when OTP 26.0.2 is released (If I understood the discussion correctly)

shahryarjb commented 1 year ago

After updating OTP 26.0.2 and delete the zed from my system I still can not use Elixir-ls formatter and autocompletion

I use asdf erlang 26.0.2 and 1.15.0-otp-26

Cervajz commented 1 year ago

@shahryarjb That's because a new version of elixir-ls (0.15.1) that fixes OTP 26 coop has not been published yet.

Zed still downloads version 0.15.0 as of now.

sergiotapia commented 1 year ago

Want to confirm without doing any "hacks" or anything like that, my ElixirLS is now working fine and I can cmd+click into modules. Thanks!

Gurp1272 commented 1 year ago

Want to confirm without doing any "hacks" or anything like that, my ElixirLS is now working fine and I can cmd+click into modules. Thanks!

Confirmed for me as well with Zed 0.92.4

ZombieHarvester commented 1 year ago

Elixir-ls 15.1 has been released, Zed has got it, and now language server works with Elixir 1.15.0 OTP 26.0.2. 🥳

shahryarjb commented 1 year ago

It seems like bugy, because if something crashed like there is no macro or sth you should delete the build and deps to compile again!!

nicklayb commented 6 months ago

I'm not sure if I'm having the same issue, but elixir-ls won't start with message

Could not run the elixir language server, `elixir-ls`, because `elixir` was not found.`

It's installed through asdf so I'm under the impression that Zed does not have the right environment when it tries to download and run the language server, asdf installed deps are probably not in the env. I tried to configure the terminal.shell setting to use my zsh shell with the right .zshrc file but that doesn't change anything (The terminal do open with the right shell though)

mrnugget commented 6 months ago

@nicklayb the terminal.shell here is unrelated. What Zed tries to do on startup is to load the environment in a login shell and set that on itself. Here:

https://github.com/zed-industries/zed/blob/080e25dd4531f402271c9b3fae9f0314cc19b664/crates/zed/src/main.rs#L840

When we then lookup elixir, we just use Rust's stdlib to lookup in $PATH, which by now should be the one you get when you run zsh -i -l -c 'elixir'.

Where and how is your asdf configured?

Can you create a ticket and tag me on it?

(I'm also happy to look at this together, if you want feel free to book some time here: https://calendly.com/thorsten-ball-zed/30min)