Can't make dialyzer works on Emacs + LSP setup

Hey folks, I can’t manage to make my Emacs + LSP setup to work… something is odd…

I’m using:
elixir 1.16.2-otp-25
erlang 25.3
Emacs 29.3

I’m using asdf to install elixir and erlang.

My lsp config:

(use-package lsp-mode
  :hook ((elixir-mode . lsp))
  :commands lsp
  :init
  (add-to-list 'exec-path *elixir-ls-path*))

I added that add-to-list to make some tests, because I saw that in some issues, but it seems it didn’t change anything… I was getting the same error before adding it…

And I’m getting this error in the lsp-log buffer:

11:16:20.484 [error] Task #PID<0.334.0> started from #PID<0.333.0> terminating
** (UndefinedFunctionError) function :dialyzer_options.build/1 is undefined (module :dialyzer_options is not available)
    :dialyzer_options.build([report_mode: :quiet, erlang_mode: true, analysis_type: :plt_build, files: [~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/auth.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Inspect.URI.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/stdlib-4.3/ebin/zip.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.String.Chars.Integer.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/mix/ebin/Elixir.Mix.Tasks.Archive.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Module.Types.Helpers.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Module.Types.Pattern.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/compiler-8.2.4/ebin/beam_trim.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Inspect.Tuple.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/compiler-8.2.4/ebin/beam_ssa_opt.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/iex/ebin/Elixir.IEx.Info.Any.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/stdlib-4.3/ebin/otp_internal.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/mix/ebin/Elixir.Mix.Tasks.Local.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/application.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/inet_dns.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.File.RenameError.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/compiler-8.2.4/ebin/core_lib.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/inet6_udp.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/mix/ebin/Elixir.Mix.Error.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.IO.ANSI.Docs.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/stdlib-4.3/ebin/unicode_util.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/os.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Collectable.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/mix/ebin/Elixir.Mix.Project.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/stdlib-4.3/ebin/erl_abstract_code.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/elixir_erl_compiler.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/elixir_locals.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/iex/ebin/Elixir.IEx.Info.BitString.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Kernel.Typespec.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/inet_hosts.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/inet_config.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/iex/ebin/Elixir.IEx.Info.Time.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Date.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/mix/ebin/Elixir.Mix.Tasks.Deps.Precompile.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.Enumerable.Date.Range.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/Elixir.IO.ANSI.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/compiler-8.2.4/ebin/cerl_inline.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/elixir/ebin/elixir_dispatch.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/file.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/stdlib-4.3/ebin/array.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/erl_erts_errors.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/stdlib-4.3/ebin/filelib.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/logger/ebin/Elixir.Logger.Backends.Console.beam", ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/bin/../lib/iex/ebin/Elixir.IEx.Info.Port.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/compiler-8.2.4/ebin/beam_ssa_share.beam", ~c"**home-dir**/.asdf/installs/erlang/25.3/lib/kernel-8.5.4/ebin/seq_trace.beam", ...], from: :byte_code, output_plt: ~c"**home-dir**/.asdf/installs/elixir/1.16.2-otp-25/.mix/elixir-ls-25.3_elixir-1.16.2"])
    dialyzer.erl:156: :dialyzer.run/1
    (language_server 0.8.2) lib/language_server/dialyzer/manifest.ex:146: ElixirLS.LanguageServer.Dialyzer.Manifest.build_elixir_plt/0
    (language_server 0.8.2) lib/language_server/dialyzer/manifest.ex:14: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.Manifest.build_new_manifest/0
    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
Function: #Function<2.124754306/0 in ElixirLS.LanguageServer.Dialyzer.Manifest.build_new_manifest/0>
    Args: []

Did you install elixir-ls yourself? I find that I sometimes have to rebuild it using a version of elixir that matches my project.

e.g. if the source code lives in ~/elixir-ls then:

cd ~/elixir-ls
vim .tool-versions
# edit tool-versions to match your project
asdf install
MIX_ENV=prod mix compile
MIX_ENV=prod mix elixir_ls.release2 -o <release_dir>

something like that, please don’t just copy-paste what I wrote.

To be honest, I wasn’t trying to do the installation by hand… I just added the LSP package on my Emacs and everything was solved… at least it was like that some months ago when I tried last time.

This time, since I’m having problems, I tried to download the .zip from the github, pointing the LSP Emac’s package to that directory and I got the same error…

Now, after your message, I cloned the repo, build it using my versions, pointed the LSP Emac’s package to the release directory and go the same error again…

I have no other ideas :frowning:

last time I checked the lsp-mode package was using a version of the elixir-ls that had issues. you can set the elixir-ls version by overwriting lsp-elixir-ls-version.
I have something like on my config:

(setq lsp-elixir-ls-version "v0.20.0")
1 Like

It could be that!

I manage to make it work using Elixir 1.14… I’ll try with 1.16 and forcing the elixir-ls version on my configuration…

this value i mentioned change the elixir-ls version that the lsp-mode script downloads through lsp-install-server
afaik, it downloads the prebuilt one with the most recent elixir that is available here:

Interesting… the value was v0.20.0 and I changed to the last one v0.21.2 and then I run the lsp-install-server again, because it seems it didn’t work for the first time… and now, it’s working :slight_smile:

Thanks

1 Like