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
Are you using relx to build your releases? Or distillery? Or the new elixir releases?
benwilson512
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: mix release — Mix v1.20.2
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








