Owens
Hello all,
I’ve set up an API key in my dev.exs config but my Phoenix app isn’t reading it. It works in iex console.
sendgrid_api_key =
System.get_env("SENDGRID_API_KEY") ||
raise """
environment variable SENDGRID_API_KEY is missing.
"""
Leads to
$ iex -S mix phx.server
** (RuntimeError) environment variable SENDGRID_API_KEY is missing.
But in IEX console
iex> System.get_env("SENDGRID_API_KEY")
Outputs the correct key.
I set this variable using
$ export SENDGRID_API_KEY='MY_API_KEY'
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
axelson
If this is in your
config/dev.exs:Then everything would generally appear to be correct. How are you starting the iex session that is working? You could also verify with
env | grep SENDGRID_API_KEYin the terminal before runningiex -S mix phx.server.If that doesn’t work then it will probably be necessary to look at the rest of your
config.exsandconfig/dev.exs. Another debugging step would be to addIO.inspect(System.get_env())right before you try to read the environment variable.Owens
Correct, that is in my config/dev.exs
env | grep SENDGRID_API_KEY works propery
I added IO.inspect
This outputs nil to the console.
derek-zhou
how about just
Owens
Thanks for the idea, just tried it and still doesn’t work.
NobbZ
I assume this is copied from a website?
Have you tried to delete and manually enter the argument to
System.get_env/1to make sure it doesn’t contain any unprintable charaters from copying?Owens
this is copied from
prod.secret.exsI tried IO.inspecting
System.get_env/0and that worked, but the environment variables are all different than what I am seeing in iex console. I am wondering if it has something to do with the new zsh console on mac. It looked to me like the things output in development were from my bash environment.Will report back as I dig deeper.
dimitarvp
So, do you have the env vars in your
~/.zshrcfile? Or, do you use thedirenvprogram with a local.envrcfile (in your repo)?Owens
I keep them in my
~/.zshrcwingyplus
I think that
zshhasenv. So should seeSECRET_KEY_BASEin the output fromenvcommand.Owens
So I took a recommendation from @NobbZ and changed the code to output all the env variables:
When I run
iex -S mix phx.server59 environment variables show (NOT including the one I want), but when I runiex -S mixonly 39 show (including the one I want).Solution
I took a gamble and just ran
$ export SENDGRID_API_KEY='MY_API_KEY'again, now everything is working!Not sure why it didn’t work the first time, oh well. My guess is quitting terminal and reloading it might have also fixed this.