I'm having some issues with SECRET_KEY_BASE
setting on our production Ubuntu server with Unicorn and nginx. I added the variable to .bashrc
and its reading fine when I try echo $SECRET_KEY_BASE
, but for some reason I'm getting the following error:
app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)
Also, when I try to access the variable with ENV["SECRET_KEY_BASE"]
from within the console in production environment, I can read it fine.
I tried restarting Unicorn and server and it doesn't help. Any idea why this is happening?
You may need to add the variables to the unicorn.conf
file, since it seems you are launching Unicorn with a different user or without sourcing your .bashrc
.
In any case, I suggest you use dotenv gem to store your env variables in a .env
file within your project. That is the cleanest way I know. If you need to have capistrano
integration and handle all the different environments with ease, you can also use dotenv-deployment gem.