Fl4m3Ph03n1x

Fl4m3Ph03n1x

Background

I am trying dialyxir to find out if it is worth it, however I have a bunch of errors on the compile phase and I want to fix them.

What did you do?

Created a pet project to try out dialyzer with dialyxir.

  1. mix new dialzyer_project
  2. cd dialyzer_project
  3. Install dialyxir globally
  4. Added the dialyxir dependency
  5. mix dialyzer

After this, I see a ton of red messages on my screen:

Finding suitable PLTs
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :stdlib]
Looking up modules in dialyxir_erlang-21.1_elixir-1.7.3_deps-dev.plt
Looking up modules in dialyxir_erlang-21.1_elixir-1.7.3.plt
Finding applications for dialyxir_erlang-21.1_elixir-1.7.3.plt
Finding modules for dialyxir_erlang-21.1_elixir-1.7.3.plt
Checking 185 modules in dialyxir_erlang-21.1_elixir-1.7.3.plt
Adding 230 modules to dialyxir_erlang-21.1_elixir-1.7.3.plt
:dialyzer.run error: Analysis failed with error:
Could not scan the following file(s):
  Could not get Core Erlang code for: /home/fl4m3/.asdf/installs/elixir/1.7.3/lib/elixir/ebin/elixir_tokenizer.beam
  Recompile with +debug_info or analyze starting from source code  Could not get Core Erlang code for: /home/fl4m3/.asdf/installs/elixir/1.7.3/lib/elixir/ebin/elixir_parser.beam
  Recompile with +debug_info or analyze starting from source code  Could not get Core Erlang code for: /home/fl4m3/.asdf/installs/elixir/1.7.3/lib/elixir/ebin/elixir_utils.beam
... 

Seems that every possible Erlang package has this issue.
But astonishingly enough, the command still analyses the project and still shows errors. I have installed erlang and elixir using asdf.

Question

How can I fix the compile errors?

Showing Posts 1 to 10

NobbZ

NobbZ

Check your OTP version and the version of elixir, especially which OTP version was used to compile it.

Both OTP versions need to be either greater than or equal to 21 or lesser than that. It’s not allowed to have one at 21 and one at 20.

My guess is that you have installed a current OTP and also are using a precompiled elixir version. Those are compiled with OTP 19 as far as I remember.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

This is the result of asdf current:

elixir         1.7.3   (set by /home/fl4m3/.tool-versions)
erlang         21.1    (set by /home/fl4m3/.tool-versions)

Questions:

  1. Could it be because these are not set as global?
  2. Could it be because I no $MIX_HOME env variable set?

Checking the docs on dialyxir I found this:

Running the mix task dialyzer by default builds several PLT files:

  • A core Erlang file in $MIX_HOME/dialyxir_erlang-[OTP Version].plt
  • A core Elixir file in $MIX_HOME/dialyxir_erlang-[OTP Version]_elixir-[Elixir Version].plt
  • A project environment specific file in _build/env/dialyze_erlang-[OTP Version]_elixir-[Elixir Version]_deps-dev.plt
NobbZ

NobbZ

Please open up iex and check the banner for the very exact version of elixir. Usually it tells you something like “compiled with”.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

dialyzer_playground$ iex -S mix
Erlang/OTP 21 [erts-10.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Compiling 5 files (.ex)
Generated dialyzer_playground app
Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

Like this?

I have updated the original post with more information about the error. I am sure the PLT tables are not being built correctly, but at this point I have no idea on how to fix it.

jeremyjh

jeremyjh

You need to asdf local elixir 1.7.3-otp-21.

That will get you the Elixir that is precompiled with the correct version of OTP.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

Thanks for popping in!

After a long time of waiting, it finally finished, but now I have the following warnings/errors:

Finding suitable PLTs
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :stdlib]
PLT is up to date!
No :ignore_warnings opt specified in mix.exs and default does not exist.

Starting Dialyzer
[
  check_plt: false,
  init_plt: '/home/fl4m3/Workspace/elixir_and_otp_guidebook/dialyzer_playground/_build/dev/dialyxir_erlang-21.1_elixir-1.7.3_deps-dev.plt',
  files_rec: ['/home/fl4m3/Workspace/elixir_and_otp_guidebook/dialyzer_playground/_build/dev/lib/dialyzer_playground/ebin'],
  warnings: [:unknown]
]
** (UndefinedFunctionError) function Dialyxir.Project.filter_warnings/1 is undefined or private. Did you mean one of:

      * filter_legacy_warnings/1
      * filter_legacy_warnings/2
      * filter_warning?/1

Am I missing some config flag?

I am using the {:dialyxir, "~> 1.0.0-rc.4", only: [:dev], runtime: false}, perhaps it is not stable enough?

NobbZ

NobbZ

Please try again with master, if the error remains please file a bug report at Issues · jeremyjh/dialyxir · GitHub and use one of the older RCs until the issue has been resolved and a new release (candidate) is available.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

@NobbZ Thanks for the input, I have now created issues in the project’s page.
Once ( if ) the issue gets resolved, I will updated this discussion so future readers can also benefit from my findings or in case someone goes through the same.

slashdotdash

slashdotdash

Thanks for the tip @jeremyjh.

I’ve been struggling with Dialyzer usage and didn’t realise it was because I needed to install the appropriate Elixir/OTP version when using asdf (as below).

asdf install erlang 21.1.1
asdf install elixir 1.7.4-otp-21
asdf global erlang 21.1.1
asdf global elixir 1.7.4-otp-21
Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

Fixed the issue. Turns out I had a lingering version of dialyxir isntalled globally with asdf elixir 1.7.3-otp-21 . I had to go to ~/.asdf/installs/elixir/1.7.3-otp-21/.mix/archives and manually delete the dialyxir folder.

Once I did that, everything worked out perfectly. So as a cautionary tale of advise for future readers, never install dialyxr locally and globally.

If you have dialyxir installed globally, make sure none of your projects has a local reference to it, or you will be in for a world of pain.

Special thanks to @NobbZ for helping out with the Git issue.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews