0

EDIT: I figured it out in the end. Decided to just manually place the master.key on the server in the cap/shared/config and then symbolic link this to each release upon deploy. It works now.


I've setup rails credentials on my production environment. I've put the RAILS_MASTER_KEY into the ubuntu ENV. It's stored in .bashrc and .profile.

In IRB on the server I can type the following command and access the secret key ENV['RAILS_MASTER_KEY]

However when I do my Capistrano deploy it tells me it can't find the secret key.

In my rails app I've edited the /config/environments/production.rb to include:

config.require_master_key = true
Rails.application.credentials.secret_key_base = ENV['RAILS_MASTER_KEY']

But the server won't recognise the secret key.

I am not using DotEnv or Figaro.

Error log below.

ActiveSupport::EncryptedFile::MissingKeyError: Missing encryption key to decrypt file with. Ask your team for your master key and write it to /var/www/appn_name/releases/20190429180042/
Richard Jarram
  • 899
  • 11
  • 22
  • 1
    As explained in the duplicate `.bashrc` set shell variables and `.profile` is a user specific shell initialization script/file. Which works great if you are using SSH to open a shell - but not for Capistrano which is not running in a shell. – max Apr 29 '19 at 19:02
  • I figured it out in the end. Decided to just manually place the master.key on the server in the cap/shared/config and then symbolic link this to each release upon deploy. It works now. – Richard Jarram Apr 29 '19 at 19:31

0 Answers0