Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elixir LS failing to download #6179

Closed
1 task done
nbernardes opened this issue Jun 20, 2023 · 23 comments · Fixed by #2646
Closed
1 task done

Elixir LS failing to download #6179

nbernardes opened this issue Jun 20, 2023 · 23 comments · Fixed by #2646

Comments

@nbernardes
Copy link

nbernardes commented Jun 20, 2023

Check for existing issues

  • Completed

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
Copy link

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
Copy link

For the Zed folks: #6178 looks like a duplicate

@mattbaker
Copy link

mattbaker commented Jun 20, 2023

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 :)

@nbernardes
Copy link
Author

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
Copy link
Author

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
Copy link

benvp commented Jun 22, 2023

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
Copy link

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
Copy link

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
Copy link

❤️ 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
Copy link

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

@joebno
Copy link

joebno commented Jun 23, 2023

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

@jvelez1
Copy link

jvelez1 commented Jun 24, 2023

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

  • delete the elixir-ls in /Library/Application Support/Zed/languages
  • adding the LSP in the settings.json
    "lsp": { "Elixir": {} }
  • reload zed (everything will crash, but it should recreate the folder in /Library/Application Support/Zed/languages)
  • Finally do the ln -s ../elixir-ls/release/language_server.sh elixir-ls in Zed/languages

@zimt28
Copy link

zimt28 commented Jun 27, 2023

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
Copy link

joebno commented Jun 27, 2023

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
Copy link

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
Copy link

benvp commented Jun 28, 2023

Oh, I misread that. Sorry!

@Cervajz
Copy link

Cervajz commented Jun 28, 2023

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)

ForLoveOfCats referenced this issue Jun 29, 2023
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Closes
https://linear.app/zed-industries/issue/Z-665/add-a-mechanism-for-detecting-and-fixing-broken-language-server
Fixes https://github.com/zed-industries/community/issues/1671
Fixes https://github.com/zed-industries/community/issues/1691
Fixes https://github.com/zed-industries/community/issues/1524
Fixes https://github.com/zed-industries/community/issues/1352
Fixes https://github.com/zed-industries/community/issues/1109
Fixes https://github.com/zed-industries/community/issues/996
Fixes https://github.com/zed-industries/community/issues/782

Things this PR does:
 - Updates our elixir-ls fetching to use new release name format
 - Detect when a server fails to launch
   - If the adapter claims to be reinstallable, get a test binary
   - If the test binary fails to launch or returns a failure error code
   - Clear container dir and reinstall
 - Detect/fix broken Node
 
Things it does not do:
- Restart server on failure, I have most of the stuff for this already
so it should be a fast follow up
 - Detect/fix broken Copilot

Node and Copilot shouldn't be too bad, they are handled via different
mechanisms. Originally I put effort into detecting failure of the server
during normal operation post launch, but that's not really needed. If
the server gets borked while running then we'll catch that on next
startup. Realizing that allowed for pruning a bunch of the work I did
and made the overall system a lot nicer

Copilot is nominally a language server but does not have an adapter and
does not run through the same mechanism in the project.

We're going to have an issue with multiple language server instances in
different projects once we add a "Reinstall Language Server" action,
which is why it's not in this PR. Each project has its own list of
server instances and is currently vaguely responsible for managing the
installations which means they can step on each others toes. This should
change, probably

Release Notes:
- Added a mechanism to detect and reinstall broken language servers
([#1691](https://github.com/zed-industries/community/issues/1691))
([#1524](https://github.com/zed-industries/community/issues/1524))
([#1352](https://github.com/zed-industries/community/issues/1352))
([#1109](https://github.com/zed-industries/community/issues/1109))
([#996](https://github.com/zed-industries/community/issues/996))
([#782](https://github.com/zed-industries/community/issues/782)).
@shahryarjb
Copy link

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
Copy link

Cervajz commented Jun 29, 2023

@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
Copy link

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!

@ForLoveOfCats ForLoveOfCats changed the title Elixir LS not working for asdf installed elixir/erlang versions Elixir LS failing to download Jun 29, 2023
@Gurp1272
Copy link

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
Copy link

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
Copy link

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!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.