I'm trying to run phoenix server from the command line with iex -S mix phx.server
but I keep getting warnings on compilation about unused variables.
Compilation failed due to warnings while using the --warnings-as-errors option
I don't care about these warnings as i am in the middle of development and these vars will eventually be used or tossed out. I have tried passing -h
and other sensible options, but none of them work and I can't find anything in the docs about how to get phx.server
to pass or override options to the compiler.
I've seen these docs and they haven't helped
I have tried passing the --no-compile
option but this is a no-go since it leaves me unable to recompile during development. I am currently using IO.inspect
to call the vars and this seems to be "good enough" for me to pass the unused vars check, but I would rather be able to disable this flag in the compiler rather than littering my code with IO.inspect
The error message is pretty clear on that:
Compilation failed due to warnings while using the
--warnings-as-errors
option
You have this specific flag enabled on the compiler, it returns a non-zero exit code on warnings. Since you're not passing the option manually in the command-line, it's possible that it's being:
ENV
variable (possibly by an Elixir version manager)mix
alias or taskBut most probably it's hardcoded in your Mixfile
under elixirc_options
. You can disable it like this:
# mix.exs
elixirc_options: [warnings_as_errors: false]
On a side note, to get help on compiler options, you should use elixirc
:
± % elixirc --help
Usage: elixirc [elixir switches] [compiler switches] [.ex files]
-o The directory to output compiled files
--help, -h Prints this message and exits
--ignore-module-conflict Does not emit warnings if a module was previously defined
--no-debug-info Does not attach debug info to compiled modules
--no-docs Does not attach documentation to compiled modules
--verbose Prints compilation status
--version, -v Prints Elixir version and exits
--warnings-as-errors Treats warnings as errors and return non-zero exit code
** Options given after -- are passed down to the executed code
** Options can be passed to the Erlang runtime using ELIXIR_ERL_OPTIONS
** Options can be passed to the Erlang compiler using ERL_COMPILER_OPTIONS
Also see: Get the compiler to exit if a compile-time warning is raised
If you run mix compile --warnings-as-errors=false
first, then you can run iex -S mix phx.server
without issues as it will already be compiled and should just start up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With