awful_waffle

awful_waffle

Enabling --warnings-as-errors flag?

Hello!

I recently discovered the --warnings-as-errors flag and strongly prefer the workflow of being blocked by compiler warnings. Warnings in Elixir seem to be much more important (i.e. calls to undefined functions) than what I typically see as warnings in my experience with other languages (i.e. lint errors, unused variables).

I’m currently working through a Phoenix project but found that mix phx.server --warnings-as-errors was unrecognized. Is there a way to tell mix/Elixir to use --warnings-as-errors under the hood when running phx.server?

Thank you for your help!

Marked As Solved

hauleth

hauleth

If you want to enable that flag by default you can use:

elixirc_options: [
  :warnings_as_errors
]

Also Liked

fuelen

fuelen

Hello!
--warnings-as-errors is a flag for mix compile.
What do you expect from --warnings-as-errors when running phx.server? Do not start server at all?
If so, then this command may help:

$ mix do compile --warnings-as-errors, phx.server
awful_waffle

awful_waffle

Thanks for the responses!

Adding elixirc_options: [warnings_as_errors: true] to my project in mix.exs achieved my goal! Now warnings display as errors when I am working in Phoenix, which works great with live reload. If I start the server with an error, it fails to run - which is fine with me.

The only down side is that the warning itself is not printed to the browser - it just shows a generic compilation error screen. The console in which I ran mix phx.server still displays the rest of the information, at least. I assume there is a configuration setting somewhere to output those warnings to the web display, but for now I am happy.

Thank you again!

Last Post!

awful_waffle

awful_waffle

Thanks for the responses!

Adding elixirc_options: [warnings_as_errors: true] to my project in mix.exs achieved my goal! Now warnings display as errors when I am working in Phoenix, which works great with live reload. If I start the server with an error, it fails to run - which is fine with me.

The only down side is that the warning itself is not printed to the browser - it just shows a generic compilation error screen. The console in which I ran mix phx.server still displays the rest of the information, at least. I assume there is a configuration setting somewhere to output those warnings to the web display, but for now I am happy.

Thank you again!

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
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 records...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement