I’ve looked everywhere but tutorials either seem mostly to lean towards Phoenix which I do not have in my application or using an additional dependency which I am not too inclined to do
System.get_env("VARIABLE") # Nil
Application.get_env(:my_app, :variable) #NIL
System.fetch_env!("VARIABLE") #{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.ArgumentError',message=><<"could not fetch environment variable \"VARIABLE\" because it is not set">>}
However, printenv in Ubuntu and nano /etc/environment show the environment variable VARIABLE set
Another strange thing is that when I go into the interactive shell iex, System.get_env("VARIABLE") prints out the value
The application is started by the script as a daemon running as a different user. I switched users and confirmed that the environment variable is also available to them
Sorry for late response. It was midnight as we were talking in my county so had to call it a night from fatigue. My application is setup as a Systemd daemon so when the compilation is done, this is how it looks the line that will start the compiled code
I resolved this. I expected it to work out of the box as it did in my WSL configuration. However, didn’t know that systemd limited access to only variables set on service start. Thanks for your time and pointing me to the right direction with your questions