hakarabakara

hakarabakara

Reading ubuntu environment variables in elixir production app

I’m unable to get my application to read an environment variable set on Ubuntu. I keep getting the message below:

** (ArgumentError) could not fetch environment variable "VARIABLE" because it is not set

This is what I have in my prod.exs variable: System.get_env("VARIABLE") || "${VARIABLE}"

I then try to run my application as below

RELX_REPLACE_OS_VARS=true /home/app/prod/rel/my_app/bin/my_app start

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

Most Liked

NobbZ

NobbZ

Are you using relx to build your releases? Or distillery? Or the new elixir releases?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

RELX_REPLACE_OS_VARS is a very old environment variable, it was changed to REPLACE_OS_VARS=true a while ago, maybe that will help?

Generally though you want to switch to using a releases.exs file as described here: https://hexdocs.pm/mix/Mix.Tasks.Release.html

NobbZ

NobbZ

Nothing here starts your application.

How do you set it?

Systemd? Initrc? Anything else? Depending on your overal system configuration you might set the environment explicitely in the services start script.

hakarabakara

hakarabakara

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

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement