ElixirLS extension for VSCode not starting on Ubuntu

I am brand new to Elixir.

The ElixirLS extension doesn’t start for me in VSCode.

After I open VSCode in a project called “project” and load a .ex file, I get some flashed messages:

  • ElixirLS - project client: couldn’t create connection to server.
  • Pending response rejected since connection got disposed
  • The ElixirLS - project server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
** (UndefinedFunctionError) function ElixirLS.LanguageServer.CLI.main/0 is undefined (module ElixirLS.LanguageServer.CLI is not available)
    ElixirLS.LanguageServer.CLI.main()
    nofile:1: (file)
    (stdlib 6.1.2) erl_eval.erl:904: :erl_eval.do_apply/7
    (elixir 1.18.0-dev) lib/code.ex:572: Code.validated_eval_string/3
[Error - 20:42:32] The ElixirLS - aoc24 server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 20:42:32] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 20:42:32] ElixirLS - aoc24 client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 20:42:32] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097

My symptoms are almost identical to this thread from 2023: ElixirLS (VSCode extension) installation issue on WSL2, Ubuntu

The solution in that case was to downgrade from ElixirLS 0.14.0 to 0.13.0. However, I’m already on 0.13.0, and in fact, that is the most recent version available for me through the VSCode Extension installer.

I have elixir installed through asdf. “elixir”, “mix”, and “iex” all work fine. I think I have “hex” installed too: the output of “mix local.hex” is

Found existing entry: /home/david/.asdf/installs/elixir/main/.mix/archives/hex-2.1.1
Are you sure you want to replace it with "https://builds.hex.pm/installs/1.16.0/hex-2.1.1.ez"? [Yn]

I am running Ubuntu 22.04.

* Elixir & Erlang versions (elixir --version): Erlang/OTP 27 [erts-15.1.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Elixir 1.18.0-dev (d97b29f) (compiled with Erlang/OTP 25)

* VSCode ElixirLS version: 0.13.0
* Operating System Version: linux 6.8.0-49-generic

Your versions are a bit off. You are using latest elixir (1.18) but your elixir-ls version is 0.13 which is almost 2 years old.

Elixir 1.18 is not yet supported by elixir ls as per crash with elixir 1.18 · Issue #1145 · elixir-lsp/elixir-ls · GitHub

You can either wait for the next version or use 1.17 with elixirls 0.25.0

3 Likes

Sorry for the slow response here, I was away over Christmas.

Thanks for the explanation. I also had an old VSCode not compatible with versions of elixirls greater than 0.13.0, which explains why it chose that version.

Elixirls is working fine for me now after:

  • upgrading VSCode to 1.96.2
  • upgrading elixirls to 0.25.0
  • downgrading elixir to 1.17.3