ijdickinson
I have a Mix task that extracts the version number of the project (for use in a build pipeline):
defmodule Mix.Tasks.VersionNumber do
@moduledoc "Mix task to print the current version number to stdout"
use Mix.Task
@shortdoc "Print the current application version number"
def run(_) do
MyApp.MixProject.project |> Keyword.fetch!(:version) |> IO.puts
end
end
This all works fine. However, when I run mix dialyzer on my project, I get an error:
$ mix dialyzer
Compiling 1 file (.ex)
Finding suitable PLTs
Checking PLT...
[:asn1, :castore, :certifi, :compiler, :connection, :cowboy, :cowboy_telemetry, :cowlib,
:crypto, :dart_sass, :db_connection, :decimal, :ecto, :ecto_sql, :eex, :elixir, :esbuild,
:expo, :file_system, :finch, :geo, :geo_postgis, :gettext, :hackney, :heroicons, :hpax,
:httpoison, :idna, :jason, :kernel, :logger, :metrics, :mime, :mimerl, :mint, :mix,
:nimble_options, :nimble_pool, :parse_trans, :phoenix, :phoenix_copy, :phoenix_ecto,
:phoenix_html, :phoenix_live_dashboard, :phoenix_live_reload, :phoenix_live_view,
:phoenix_pubsub, :phoenix_template, :plug, :plug_cowboy, ...]
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/ian/projects/verna/myapp/_build/dev/dialyxir_erlang-25.1.2_elixir-1.14.2_deps-dev.plt',
files: ['/home/ian/projects/verna/myapp/_build/dev/lib/myapp/ebin/Elixir.MyApp.LocationSearch.SearchResult.beam',
'/home/ian/projects/verna/myapp/_build/dev/lib/myapp/ebin/Elixir.MyApp.beam',
'/home/ian/projects/verna/myapp/_build/dev/lib/myapp/ebin/Elixir.MyApp.Application.beam',
'/home/ian/projects/verna/myapp/_build/dev/lib/myapp/ebin/Elixir.MyApp.ReferenceData.LandRegistry.beam',
'/home/ian/projects/verna/myapp/_build/dev/lib/myapp/ebin/Elixir.MyApp.Gettext.beam',
...],
warnings: [:unknown]
]
Total errors: 1, Skipped: 0, Unnecessary Skips: 0
done in 0m4.56s
lib/mix/tasks/version_number.ex:7:unknown_function
Function MyApp.MixProject.project/0 does not exist.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2
At a guess, the problem is maybe related to project/0 being defined in an .exs file rather than .ex? Is there a way to either ignore the mix task in the Dialyzer analysis, or, better, help it to find the definition of project/0?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Billzabob
I’m having the same problem, did you ever find a solution?
ijdickinson
We switched approach, so we dropped this task from our
project.exs.However, we did find ourselves having to ignore some other Dialyzer errors. The pattern for that is to create a
./.dialyzer-ignore.exsfile, using the pattern:So in theory, this should work:
But I’ve not tested it, so ymmv.
Good luck!
Ian
al2o3cr
Dialyzer depends on the compiler, so it’s definitely not going to see modules defined in
.exsfiles.That file will be loaded by Mix at runtime before running the task, so it doesn’t actually fail.
A better approach might be to use the built-in Mix machinery, specifically
Mix.Project.config/0:kenny-evitt
This answer on the following Stack Overflow question seems to have worked to fix similar errors for one of my own projects:
The answer states that you can add the following to (the return value of) the
project/0function in your project Mix module file (i.e.mix.exs) – or add:mixto the list if the key-value pair already exists:Example
project/0function: