dwilbank
dwilbank

Reputation: 2520

ENV variables in bash - why can't I access them in my Rails local setup?

I've set my Stripe Publishable and Secret Keys in my .bash_profile, and they show up fine in bash...

> echo $STRIPE_TEST_SECRET_KEY
sk_test_bunchofcharacters

but in my stripe.rb file, they aren't getting accessed.

Rails.configuration.stripe = {
    :publishable_key => ENV['STRIPE_TEST_PUBLISHABLE_KEY'],
    :secret_key => ENV['STRIPE_TEST_SECRET_KEY'],
}

Stripe.api_key = Rails.configuration.stripe[:secret_key]
byebug

What piece am I missing?

Everything works fine in production when I do heroku config and all that... it's just this local installation that is the trouble.

P.S. The variables don't show up in my rails console either.

Upvotes: 1

Views: 48

Answers (1)

Jordan Running
Jordan Running

Reputation: 106147

Try stopping your server and then typing spring stop to stop Spring as well, and then start your server again. I think environment variables only get loaded when Spring starts.

Upvotes: 1

Related Questions