ActiveSupport::MessageEncryptor when deploy:assets:precompile

Viewed 1346

I have problem with deploy rails application to server. When I try deploy in step deploy:assets:precompile I get

 01 rake aborted!
  01 ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
  01 /var/www/spycommerce/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/message_encryptor.rb:206:in `rescue in _decrypt'
  ...
  01
  01 Caused by:
  01 OpenSSL::Cipher::CipherError:
  01 /var/www/spycommerce/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/message_encryptor.rb:201:in `final'
  ...

When I try compile assets manual RAILS_ENV=production bundle exec rake assets:precompile I not get error

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/deploy'

require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'

install_plugin Capistrano::Puma  # Default puma tasks

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

versions

rails -v => 5.2.1
capistrano -v => 3.11

I try fix with config.require_master_key = true, and create link set :linked_files, %w{config/master.key} in deploy.rb. nothing helps

1 Answers

I ran into a similar problem when testing the MessageEncryptor for a Rails Api application from the command line. A solution to prevent the InvalidMessage exception: If You have to use ActiveSupport::MessageEncryptor outside of the rails initialisation context, do manually set ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = true. MessageEncryptor then use the intended default_cipher aes-256-gcm.

Related