dialyzer fails to recognise elixir functions with error :0:unknown_function

757 Views Asked by At

I have elixir 1.7.2 on my computer installed using asdf, both elixir and erlang otp 21. On my project mix file I have added the latest release candidate of dialyzer as instructed on dialyzer github

{:dialyxir, "~> 1.0.0-rc.3", only: [:dev], runtime: false} 

When I run mix dialyzer I get a couple of errors when its creating the plt among them being:

Could not get Core Erlang code for: /home/sigu/.asdf/installs/elixir/1.7.2/lib/elixir/ebin/elixir_parser.beam

Recompile with +debug_info or analyze starting from source code  Could not get Core Erlang code for: /home/sigu/.asdf/installs/elixir/1.7.2/lib/logger/ebin/Elixir.Logger.ErlangHandler.beam

Everything then fails with errors included the elixir built in functions like System.get_env/1

:0:unknown_function
Function System.get_env/1 does not exist.
1

There are 1 best solutions below

1
On BEST ANSWER

Turns out the error is being caused by the fact that when I installed elixir, asdf uses a version precompiled with erlang otp-20. When dialyzer tries to create the plt, it fails to find elixir 1.7.2 compiled with otp-21.

To work around this, install elixir precompiled with otp-21 as instructed on the asdf/elixir github - Thanks to the elixir slack where I found the solution

asdf install elixir 1.7.2-otp-21

Command installs elixir precompiled with otp-21.

Everything should work as expected now