abritov

abritov

Getting Dialyzer errors: Callback info about the Plug behaviour is not available, and functions 'do not exist'

Hello!

I use elixir with asdf and mix dialyzer emits errors like that:

deps/plug/lib/plug/router.ex:1:callback_info_missing
Callback info about the Plug behaviour is not available.
________________________________________________________________________________
deps/plug/lib/plug/router.ex:234:unknown_function
Function Plug.Router.Utils.decode_path_info!/1 does not exist.
________________________________________________________________________________
deps/plug/lib/plug/router.ex:242:unknown_function
Function :telemetry.span/3 does not exist.
________________________________________________________________________________

I tried this fixes from google:

  • Changing envs (dev/test/no env) when running dialyzer
  • Setting different elixir/erlang versions in .tool-versions
  • Setting elixir version to 1.16.2-otp-26 and erlang to 26.0.1 so they should match
  • Setting plt_apps & plt_add_apps and plt_add_deps: :apps_direct to make dialyzer scan only specified dependencies

But none of that worked. Any ideas on how to fix that errors?
Here is a project where I reproduced things above

Thank you all in advance :raised_hands:

Marked As Solved

al2o3cr

al2o3cr

I wasn’t able to fix the error, but I was able to move the crash site somewhat: See the bottom for the rest of the story…

  • removed the stray close-square-bracket present in 0b8736d which blocks running any Mix task
  • removed all of the plt_* options from the Dialyzer config
  • remove :mix and :hex from extra_applications - that one in particular silences the Could not get Core Erlang code for: /Users/mattjones/.asdf/installs/elixir/1.16.2-otp-26/.mix/archives/hex-2.1.1/hex-2.1.1/ebin/Elixir.Hex.Crypto.PublicKey.beam chatter before the main Dialyzer results
  • added {:hex_core, "~> 0.11.0"}, to deps
  • updated all the references to :mix_hex_* to instead use the corresponding hex_core modules named :hex_*

This results in a compiler error:

==> dialyzer_error_rep
Compiling 5 files (.ex)
     warning: Hex.Shell.info/1 is undefined (module Hex.Shell is not available or is yet to be defined)
     │
 141 │         Hex.Shell.info("* public key at #{path} does not match private key, overwriting")
     │                   ~
     │
     └─ lib/dialyzer_error_rep/registry_builder.ex:141:19: DialyzerErrorRep.RegistryBuilder.ensure_public_key/2
     └─ lib/dialyzer_error_rep/registry_builder.ex:151:17: DialyzerErrorRep.RegistryBuilder.create_directory/1
     └─ lib/dialyzer_error_rep/registry_builder.ex:158:17: DialyzerErrorRep.RegistryBuilder.write_file/2
     └─ lib/dialyzer_error_rep/registry_builder.ex:161:17: DialyzerErrorRep.RegistryBuilder.write_file/2
     └─ lib/dialyzer_error_rep/registry_builder.ex:168:15: DialyzerErrorRep.RegistryBuilder.remove_file/1

as well as the equivalent Dialyzer error:

lib/dialyzer_error_rep/registry_builder.ex:141:unknown_function
Function Hex.Shell.info/1 does not exist.
________________________________________________________________________________
lib/dialyzer_error_rep/registry_builder.ex:151:unknown_function
Function Hex.Shell.info/1 does not exist.
________________________________________________________________________________
lib/dialyzer_error_rep/registry_builder.ex:158:unknown_function
Function Hex.Shell.info/1 does not exist.
________________________________________________________________________________
lib/dialyzer_error_rep/registry_builder.ex:168:unknown_function
Function Hex.Shell.info/1 does not exist.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

Looking at the definition of Hex.Shell.info/1, it’s a trivial wrapper over Mix.shell().info/1.

Replacing those calls in RegistryBuilder causes Dialyzer to emit a new complaint:

lib/dialyzer_error_rep/registry_builder.ex:141:unknown_function
Function Mix.shell/0 does not exist.
________________________________________________________________________________
lib/dialyzer_error_rep/registry_builder.ex:151:unknown_function
Function Mix.shell/0 does not exist.
________________________________________________________________________________
lib/dialyzer_error_rep/registry_builder.ex:158:unknown_function
Function Mix.shell/0 does not exist.
________________________________________________________________________________
lib/dialyzer_error_rep/registry_builder.ex:168:unknown_function
Function Mix.shell/0 does not exist.
________________________________________________________________________________
done (warnings were emitted)

This can finally be silenced by adding plt_add_apps: [:mix], to the Dialyzer config in mix.exs, producing a clean Dialyzer report!

Generated dialyzer_error_rep app
Finding suitable PLTs
Checking PLT...
[:asn1, :compiler, :cowboy, :cowboy_telemetry, :cowlib, :crypto, :dialyzer_error_rep, :eex, :elixir, :hex_core, :inets, :kernel, :logger, :mime, :mix, :plug, :plug_cowboy, :plug_crypto, :public_key, :ranch, :ssl, :stdlib, :telemetry]
Looking up modules in dialyzer.plt
Finding applications for dialyzer.plt
Finding modules for dialyzer.plt
Checking 852 modules in dialyzer.plt
Adding 95 modules to dialyzer.plt
done in 0m3.48s
ignore_warnings: dialyzer_ignore.exs

Starting Dialyzer
[
  check_plt: false,
  init_plt: ~c"/Users/mattjones/src/dialyzer-unknown-error-rep/dialyzer_cache/dialyzer.plt",
  files: [~c"/Users/mattjones/src/dialyzer-unknown-error-rep/_build/dev/lib/dialyzer_error_rep/ebin/Elixir.DialyzerErrorRep.Application.beam",
   ~c"/Users/mattjones/src/dialyzer-unknown-error-rep/_build/dev/lib/dialyzer_error_rep/ebin/Elixir.DialyzerErrorRep.RegistryBuilder.beam",
   ~c"/Users/mattjones/src/dialyzer-unknown-error-rep/_build/dev/lib/dialyzer_error_rep/ebin/Elixir.DialyzerErrorRep.Router.beam",
   ~c"/Users/mattjones/src/dialyzer-unknown-error-rep/_build/dev/lib/dialyzer_error_rep/ebin/Elixir.DialyzerErrorRep.Static.beam",
   ~c"/Users/mattjones/src/dialyzer-unknown-error-rep/_build/dev/lib/dialyzer_error_rep/ebin/Elixir.HexRegistry.beam"],
  warnings: [:unknown]
]
Total errors: 0, Skipped: 0, Unnecessary Skips: 0
done in 0m1.33s
done (passed successfully)

Also Liked

al2o3cr

al2o3cr

Where Next?

Popular in Questions Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

We're in Beta

About us Mission Statement