Setting environment variables in Erlang applications
-
07-07-2021 - |
Question
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.
OTHER TIPS
Did you forget application:start(cw)
first?
If application not started, the env is undefined.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow