figaro: Figaro doesn't work with Rails 4.1 in test environment
I’m using Rails 4.1 and, since I prefer Figaro to the new secrets.yml, I installed it and put the following in config/application.rb:
# ...
module MyApp
class Application < Rails::Application
# ...
config.time_zone = ENV['TIME_ZONE']
config.i18n.default_locale = ENV['DEFAULT_LOCALE']
# ...
end
end
I also have other similar settings in my initializers, but for some reason my application doesn’t see any of the environment variables in the test environment.
Is this a known issue? Do you have a workaround?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 18 (8 by maintainers)
Just an FYI that the recommendation to restart spring solved this issue for me. Thanks @odigity!
First thing to try is removing Spring from your Gemfile, running bundle, and killing all Spring processes. I lost a week to unreliable env var behavior until I realized Spring was the culprit.
I still can’t believe Rails is including it by default. Worst decision ever.
Here you go.
EDIT: Oh, wait. I’ve just noticed that I put Figaro in the
developmentgroup. I’m such an idiot.Indeed, Figaro 0.7.0 works fine with Rails 4.1. I’m so sorry for wasting your time. I had never put Figaro in a group so I didn’t even bother to look in my
Gemfile.Thank you. This is obviously buggy behavior, but there are a few things going on here:
application.rbunless you manuallyFigaro.loadfirst.Does it work if you use Figaro master?