Closed ghost closed 4 years ago
If you are using mix
application at runtime, you need to included it in your extra_applications
key in your mix.exs
. We're not encouraged to use Mix at runtime in our applications, since it is a build tool. If you are using mix release
you probably don't want to be using Mix.env()
.
I'm not running Mix at runtime, it's used completely at compile time for conditional compilation.
I fixed the Dialyzer warnings with the unquote
macro doing this:
if unquote(Mix.env() == :prod) do
Environment
Tested on three different machines/environments.
Elixir 1.10.4 (compiled with Erlang/OTP 22)
Erlang/OTP 23 [erts-11.0] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1]
Elixir 1.10.4 (compiled with Erlang/OTP 21)
Erlang/OTP 22 [erts-10.7.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Elixir 1.10.4 (compiled with Erlang/OTP 22)
Total errors: 1, Skipped: 0, Unnecessary Skips: 0 done in 0m6.08s :0:unknown_function Function Mix.env/0 does not exist.
done (warnings were emitted) Halting VM with exit status 2
{:warn_unknown, {[], 0}, {:unknown_function, {Mix, :env, 0}}}