elixir-lsp / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
https://elixir-lsp.github.io/elixir-ls/
Apache License 2.0
1.5k stars 196 forks source link

Elixir LS immediately crashes with `badmatch` error #1041

Closed rpbaptist closed 11 months ago

rpbaptist commented 11 months ago

Environment

Current behavior

When launching launch.sh or language_server.sh a crash immediately occurs. Both in Neovim, Sublime Text and directly from the command line:

❯ ~/.elixir-ls/language_server.sh
Running /home/richard/.elixir-ls/launch.sh
Preferred shell is zsh, relaunching
Looking for ASDF install
ASDF not found
Looking for rtx executable
rtx executable found in /usr/bin/rtx, activating
init terminating in do_boot ({{badmatch,{error,{elixir,{_}}}},[{elixir,start_cli,0,[{_},{_}]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
❯ ~/.elixir-ls/launch.sh
Preferred shell is zsh, relaunching
Looking for ASDF install
ASDF not found
Looking for rtx executable
rtx executable found in /usr/bin/rtx, activating
init terminating in do_boot ({{badmatch,{error,{elixir,{_}}}},[{elixir,start_cli,0,[{_},{_}]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done

Expected behavior

I expect the LS to start.

lukaszsamson commented 11 months ago

Most likely there's something wrong with either your elixir or OTP install. After rtx activate the launch script attempts to exec an install script via elixir command, and that fails. It looks like your elixir is built for other OTP version than the one that rtx activates

rpbaptist commented 11 months ago

Thanks for the hint. After some debugging of the launch script I found the following error:

=ERROR REPORT==== 21-Dec-2023::12:23:42.261095 ===
beam/beam_load.c(184): Error loading module 'Elixir.Kernel':
  This BEAM file was compiled for a later version of the runtime system than the current (Erlang/OTP 25).
  To fix this, please re-compile this module with an Erlang/OTP 25 compiler.
  (Use of opcode 182; this emulator supports only up to 180.)

I am using OTP 26 in my project along with Elixir 1.15.7. I cleaned all my deps and the build. I'm not sure where this OTP 25 complied BEAM file is coming from.

lukaszsamson commented 11 months ago

Closing as this is not ElixirLS issue