# Enabling --warnings-as-errors flag?

**URL:** <https://forum.elixirforum.com/t/enabling-warnings-as-errors-flag/32226>\
**Category:** Questions\
**Tags:** debugging, mix, phoenix\
**Created:** [June 9, 2020, 1:48pm UTC](https://forum.elixirforum.com/t/enabling-warnings-as-errors-flag/32226 "2020-06-09T13:48:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![awful\_waffle](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/awful_waffle/32/17511_2.png) [@awful\_waffle](https://forum.elixirforum.com/u/awful_waffle)\
**Post date:** [June 9, 2020, 1:48pm UTC](https://forum.elixirforum.com/t/enabling-warnings-as-errors-flag/32226/1 "2020-06-09T13:48:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![fuelen](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fuelen/32/9870_2.png) [@fuelen](https://forum.elixirforum.com/u/fuelen)\
**Post date:** [June 9, 2020, 6:51pm UTC](https://forum.elixirforum.com/t/enabling-warnings-as-errors-flag/32226/2 "2020-06-09T18:51:23Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![hauleth](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/32/18942_2.png) [@hauleth](https://forum.elixirforum.com/u/hauleth)\
**Post date:** [June 9, 2020, 8:31pm UTC](https://forum.elixirforum.com/t/enabling-warnings-as-errors-flag/32226/3 "2020-06-09T20:31:30Z")

</div>

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

```elixir
elixirc_options: [
  :warnings_as_errors
]

```

---

<div class="post-metadata">

**Author:** ![awful\_waffle](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/awful_waffle/32/17511_2.png) [@awful\_waffle](https://forum.elixirforum.com/u/awful_waffle)\
**Post date:** [June 12, 2020, 5:49pm UTC](https://forum.elixirforum.com/t/enabling-warnings-as-errors-flag/32226/4 "2020-06-12T17:49:21Z")

</div>

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!
