0

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?

indhu
  • 91
  • 7

2 Answers2

0

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

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
  • could you elaborate more about usage of runtime.exs. Still i am getting nil with System,get_env(ENABLE_XXX) from the module – indhu Dec 12 '22 at 11:49
0

with env.bat:

call env.bat   

and

mix phx.server 

did the trick.

Jeff Schaller
  • 2,352
  • 5
  • 23
  • 38
indhu
  • 91
  • 7