how to access env variables in runtime elixir (localhost) windows

801 Views Asked by At

I am using Windows machine where i have elixir project. I have env.bat file where all the environment variables are set. While running the elixir project in local, environment variables are not getting retrieved.

I have tried changing env.bat to .env and having runtime.exs but that is for prod

env.bat file set ENABLE_XXX=true
in config.exs config :app, enable: System.get_env("ENABLE_XXX")
in modulehost = Application.get_env(:app, :enable)
start servermix phx.server

when access the API call it is showing as nil. how to access enviornment variables in runtime on windows?

2

There are 2 best solutions below

1
On

Use System.get_env("ENABLE_XXX") from the module, or set it up up in config/runtime.exs.

0
On

with env.bat:

call env.bat   

and

mix phx.server 

did the trick.