Search code examples
erlangenvironmentrebar

Setting environment variables in Erlang applications


There's clearly something I don't understand about Erlang... well, among many things.

I've set up an application under Rebar called cw.I start it up and everything runs fine.

Now I want to create an environment variable so I can access the src directory. I've entered the following in cw.app.src:

{env, [{proj_root, "mypath/apps/cw"}]}

Compile, start with Rebar start.sh... everything works fine.

Now the mystery. Yesterday when I did this, I got the correct path when I entered application:get_env(cw, proj_root) in the Erlang shell. But today I get undefined.

What am I missing?

Many thanks,

LRP


Solution

  • application:load(cw) should be enough.