lexical-lsp / lexical

Lexical is a next-generation elixir language server
888 stars 82 forks source link

(Argument Error) Could not load the following modules #822

Closed JasterV closed 2 months ago

JasterV commented 2 months ago

Hi there,

I have an elixir project and when I open it I get the following error from the Lexical LSP (I'm using neovim btw)

[ERROR][2024-08-28 12:51:09] .../vim/lsp/rpc.lua:770 "rpc" "/Users/victormartinez/Documents/lexical/_build/dev/package/lexical/bin/start_lexical.sh" "stderr" '* (ArgumentError) could not load the following modules:\n\n LXSourceror due to reason :badfile\n LXSourceror.Comments due to reason :badfile\n LXSourceror.LinesCorrector due to reason :badfile\n LXSourceror.Patch due to reason :badfile\n LXSourceror.Range due to reason :badfile\n lib/future/code.ex:1827: Future.Code.ensure_all_loaded!/1\n (elixir 1.15.7) lib/enum.ex:984: Enum."-each/2-lists^foreach/1-0-"/2\n lib/lexical/server/boot.ex:25: LXical.Server.Boot.start/0\n /Users/victormartinez/Documents/lexical/_build/dev/package/lexical/bin/boot.exs:23: (file)\n'

Any clue?

JasterV commented 2 months ago

I was able to reproduce the issue myself, here are the errors:

~/Documents/lexical/_build/dev/package/lexical/bin/start_lexical.sh .
Detected Elixir through mise: /Users/victormartinez/.local/share/mise/installs/elixir/1.15.7-otp-25/bin/elixir

13:02:39.793 [error] beam/beam_load.c(190): Error loading module 'Elixir.LoggerFileBackend':
  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.)

13:02:39.793 [error] Loading of /Users/victormartinez/Documents/lexical/_build/dev/package/lexical/lib/logger_file_backend.ez/logger_file_backend/ebin/Elixir.LoggerFileBackend.beam failed: :badfile

13:02:39.811 [error] beam/beam_load.c(190): Error loading module 'Elixir.LXSourceror':
  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.)

13:02:39.812 [error] beam/beam_load.c(1001): Error loading function 'Elixir.LXSourceror.Comments':do_extract_comments/4: op i_bif2_body: ssbd:
  import 6 not a BIF

13:02:39.814 [error] beam/beam_load.c(1001): Error loading function 'Elixir.LXSourceror.LinesCorrector':correction/4: op i_bif2_body: ssbd:
  import 6 not a BIF

13:02:39.815 [error] beam/beam_load.c(190): Error loading module 'Elixir.LXSourceror.Patch':
  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.)

13:02:39.816 [error] beam/beam_load.c(190): Error loading module 'Elixir.LXSourceror.Range':
  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.)

** (ArgumentError) could not load the following modules:

  * LXSourceror due to reason :badfile
  * LXSourceror.Comments due to reason :badfile
  * LXSourceror.LinesCorrector due to reason :badfile
  * LXSourceror.Patch due to reason :badfile
  * LXSourceror.Range due to reason :badfile
    lib/future/code.ex:1827: Future.Code.ensure_all_loaded!/1
    (elixir 1.15.7) lib/enum.ex:984: Enum."-each/2-lists^foreach/1-0-"/2
    lib/lexical/server/boot.ex:25: LXical.Server.Boot.start/0
    /Users/victormartinez/Documents/lexical/_build/dev/package/lexical/bin/boot.exs:23: (file)
JasterV commented 2 months ago

Ok I've solved it. Apparently I had to compile lexical with the minimum elixir and erlang version from among all the projects I work with :)