Rails 5.1 Capistrano Deploying with secrets.yml.key

Viewed 3591

I'm attempting to deploy to a staging environment with capistrano. I've set up my encrypted secrets and tested on development, and the secrets appear available. I've setup the staging environment config for read_encrypted_secrets = true. My secret key file is git-ignored. I have ssh'ed into my staging environment and placed the secrets.yml.key in the app_name/current/config directory. I am deploying to an AWS EC2 instance. I am not using the RAILS_MASTER_KEY environment variable.

When I run cap staging deploy and choose my release tag, I run into this error during deploy:migrating bundle exec rake db:migrate

01 rake aborted!
01 Rails::Secrets::MissingKeyError: Missing encryption key to decrypt secrets with. Ask your team for your master key and put it in ENV["RAILS_MASTER_KEY"]

I have the correct key on the server, why isn't rails finding/using it?

2 Answers

This also works for Rails 5.2 and the encrypted ENV variables:

append :linked_files, "config/master.key"

Related