envy icon indicating copy to clipboard operation
envy copied to clipboard

Using Mix.env causes dialyzer error to occur.

Open edwinthinks opened this issue 5 years ago • 0 comments

Hey there~

I ran into an issue with dialyzer using Mix.env to control loading the .env file like so:

    if Mix.env() == :dev do
      Envy.auto_load()
      Envy.reload_config()
    end

Dialyzer issue:

Total errors: 1, Skipped: 0, Unnecessary Skips: 0
done in 0m1.97s
:0:unknown_function
Function Mix.env/0 does not exist.
________________________________________________________________________________
done (warnings were emitted)

I was able to circumvent this problem by adding a config value in my config/dev.exs (which should be fine since this is the only place I'll be using dotenv for my use case)

config :my_app, use_dot_env: true

and then in the application file

    if Application.get_env(:my_app, :dev) do
      Envy.auto_load()
      Envy.reload_config()
    end

This works for me and I was wondering if there is any blaring issues with this approach. If not, I think it would be good to add in the README (happy to do this if we see use in it :) )

edwinthinks avatar May 29 '19 12:05 edwinthinks