elixir-lsp/elixir-ls

(UndefinedFunctionError) function ElixirLS.LanguageServer.main/0 is undefined (module ElixirLS.LanguageServer is not available)

anildigital opened this issue · 2 comments

Precheck

Done

Environment

  • Elixir & Erlang versions (elixir --version):
 elixir --version
Erlang/OTP 24 [erts-12.3.2.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]

Elixir 1.13.3 (compiled with Erlang/OTP 23)
  • Elixir Language Server version: v0.21.3

  • Operating system: macOS Sonoma 14.5 (23F79)

  • Editor or IDE name: Zed

  • Editor Plugin/LSP Client name and version: elixir-ls plugin

Current behavior

 sh "/Users/anil/Library/Application Support/Zed/extensions/work/elixir/elixir-ls-v0.21.3/language_server.sh"
Running /Users/anil/Library/Application Support/Zed/extensions/work/elixir/elixir-ls-v0.21.3/launch.sh
Preferred shell is fish, launching launch.fish
Looking for ASDF install
ASDF install found in /opt/homebrew/opt/asdf/libexec/asdf.fish, sourcing
Installing ElixirLS release v0.21.3
Running in /Users/anil
Install complete
** (UndefinedFunctionError) function ElixirLS.LanguageServer.main/0 is undefined (module ElixirLS.LanguageServer is not available)
    ElixirLS.LanguageServer.main()
    Library/Application Support/Zed/extensions/work/elixir/elixir-ls-v0.21.3/launch.exs:18: (file)

Expected behavior

It should start the server

Please do some investigation. Something is broken on your machine.
What happens when you explicitly install in iex? Be sure to use the exact same elixir and otp

Mix.install(
      [
        {:elixir_ls, github: "elixir-lsp/elixir-ls", tag: "v0.21.3"}
      ],
      start_applications: false,
      consolidate_protocols: false
    )

It should succeed and then it should be able to start

iex(2)> ElixirLS.LanguageServer.main()
Content-Length: 103

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Started ElixirLS v0.21.3","type":3}}Content-Length: 116

Examine contents of your mix installs dir given by Mix.Utils.mix_cache() (usually /Users/<user>/Library/Caches/mix)
Check your elixir install. You use a version built for OTP 23 on OTP 24.

I deleted folders inside /Users/anil/Library/Caches/mix and restarted Zed editor (which fetched elixir-ls plugin again). This fixed the issue.