So on Ubuntu server I am getting this in my logs:
#<RuntimeError: Missing `secret_key_base` for 'production'
environment, set this value in `config/secrets.yml`>
/home/deploy/apps/project/shared/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/application.rb:510:in `validate_secret_key_config!'
/home/deploy/apps/project/shared/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/application.rb:247:in `env_config'```
My Browser:
An unhandled lowlevel error occurred. The application logs may have details.
My secrets.yml (in deploy/apps/project/current/config & deploy/apps/project/shared/config):
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
deploy.rb
...
namespace :deploy do
desc 'Rails Secrets'
task :secret do
on roles(:app) do
execute "export SECRET_KEY_BASE=`bundle exec rake secret`"
end
end
before :finishing, :secret
...
end
I have also tried manually adding the SECRET_KEY_BASE in /etc/profile. It is present when I type this command: printenv (because I manually added it), but when logging out of root it is not present anymore in printenv.
The ENV variable is not present in the printenv command. After I carry out a deployment (cap production deploy:initial).
How do I resolve this error?
Seems like the user that you are logged in is not the same user that you've used to add the secret key base. You are logged as root but I don't think you are deploying nor starting the server with
root, right?If you are a deploying with a user called
deployso to say, you should log in asdeployand add the env var to deploy's context (e.g.~/.bashrc). I'm not 100% sure that/etc/profilewill work here. Also, remember to restart the rails server after add the var