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

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
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
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New

We're in Beta

About us Mission Statement