尝试部署Rails 5.2.0 App时在日志中获取错误ActiveSupport :: MessageEncryptor :: InvalidMessage

时间:2018-07-07 15:42:45

标签: ruby-on-rails ruby-on-rails-5.2

我正在尝试使用mina deploy在ec2实例上部署Rails 5.2.0 App,当它尝试迁移数据库时,它被以下错误日志中止。

    -----> 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

我的rails应用程序中有有效的config/credentials.yml.encmaster.key。因为我在本地计算机上使用RAILS_ENV='production'尝试了rails命令,即rails db:create,rails db:migrate等。

我已经在我的ubuntu服务器上的/ app_name / shared / config /中添加了master.key文件。但是仍然遇到这个问题。

1 个答案:

答案 0 :(得分:0)

您需要添加 SECRET_KEY_BASE = 'Your_SECRET_KEY_BASE' 来做环境!

我遇到了同样的问题。相信我,关注https://blog.xuite.net/yhunglee/blog/585116240-Problems+of+deploying+rails+5.2.0+to+production 可以解决这个问题。