Getting error in logs ActiveSupport::MessageEncryptor::InvalidMessage when try to deploy Rails 5.2.0 App

匿名 (未验证) 提交于 2019-12-03 01:41:02

问题:

I'm trying to deploy a Rails 5.2.0 App on ec2 instance using mina deploy and When it tries to Migrate database it is aborted with following error logs.

    -----> Migrating database        WARNING: Use strings for Figaro configuration. 2 was converted to "2".        WARNING: Use strings for Figaro configuration. 5 was converted to "5".        I, [2018-07-07T15:15:56.316810 #15933]  INFO -- sentry: ** [Raven] Raven 2.7.4 ready to catch errors        I, [2018-07-07T15:15:56.579121 #15933]  INFO -- sentry: ** [Raven] Raven 2.7.4 ready to catch errors        [Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration.        rake aborted!        ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:206:in `rescue in _decrypt'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:183:in `_decrypt'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:79:in `decrypt'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:42:in `read'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:21:in `read'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:33:in `config'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:38:in `options'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:433:in `secret_key_base'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:176:in `key_generator'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/globalid-0.4.1/lib/global_id/railtie.rb:26:in `block (2 levels) in <class:Railtie>'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `each'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'        /var/www/myApp.com/tmp/build-153097655127872/config/environment.rb:5:in `<main>'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:337:in `require_environment!'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:520:in `block in run_tasks_blocks'        /var/www/myApp.com/tmp/build-153097655127872/vendor/bundle/ruby/2.5.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `load'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `kernel_load'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:28:in `run'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli.rb:424:in `exec'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli.rb:27:in `dispatch'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli.rb:18:in `start'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/exe/bundle:30:in `block in <top (required)>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/exe/bundle:22:in `<top (required)>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `load'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `<main>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `<main>'         Caused by:        ArgumentError: invalid base64        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:185:in `block in _decrypt'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:185:in `map'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:185:in `_decrypt'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:79:in `decrypt'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:42:in `read'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:21:in `read'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:33:in `config'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:38:in `options'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:433:in `secret_key_base'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:176:in `key_generator'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/globalid-0.4.1/lib/global_id/railtie.rb:26:in `block (2 levels) in <class:Railtie>'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `each'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'        /var/www/myApp.com/tmp/build-153097655127872/config/environment.rb:5:in `<main>'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:337:in `require_environment!'        /var/www/myApp.com/shared/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:520:in `block in run_tasks_blocks'        /var/www/myApp.com/tmp/build-153097655127872/vendor/bundle/ruby/2.5.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `load'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:74:in `kernel_load'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli/exec.rb:28:in `run'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli.rb:424:in `exec'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli.rb:27:in `dispatch'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/cli.rb:18:in `start'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/exe/bundle:30:in `block in <top (required)>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'        /home/ubuntu/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.2/exe/bundle:22:in `<top (required)>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `load'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `<main>'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'        /home/ubuntu/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `<main>'        Tasks: TOP => db:migrate => db:load_config => environment        (See full trace by running task with --trace)  !     ERROR: Deploy failed. -----> Cleaning up build        Unlinking current        OK 

I have valid config/credentials.yml.enc and master.key in my rails application. Because, I have tried rails commands at my local machine with RAILS_ENV='production' i.e. rails db:create, rails db:migrate etc.

I have added the master.key file on /app_name/shared/config/ on my ubuntu server. But still getting this issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!