Rails 5.2.0加载应用程序错误:ActiveSupport :: MessageEncryptor :: InvalidMessage(ActiveSupport :: MessageEncryptor :: InvalidMessage

时间:2018-08-10 02:23:56

标签: ruby-on-rails ruby-on-rails-5 activesupport

我尝试过解决方案,该解决方案发布在以下链接中:
Rails 5.2 with master.key Digital Ocean deployment: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage Rails Deploy Digitalocean ActiveSupport::MessageEncryptor::InvalidMessage: Getting error in logs ActiveSupport::MessageEncryptor::InvalidMessage when try to deploy Rails 5.2.0 App

,但没有人适合我的情况。

我的环境是:

  1. 同一帐户在远程计算机上部署了两个Rails 5.2.0应用程序。
  2. 首先,它们可以通过浏览器视图进行部署和使用,并用于ruby 2.4.1。这是secrets.yml的秘密。
  3. 第二个rails 5.2.0应用程序用于ruby 2.4.2,并且获取密钥的方法用于config/master.keyconfig/credentials.yml.enc。这是可部署的,但无法通过浏览器视图使用。由于提交错误,我曾经重新生成master.keycredentials.yml.enc的文件,并将其推送到git-remote存储库。
  4. 它们的两个宝石集都在同一个rvm中,命名为:rails5.2.0
  5. 通过capistranorails-capistrano gem部署
  6. 他们两个都使用phusion乘客5.3.3 + apache 2.4.7

对于第二个Rails 5.2.0应用程序,我使用gem dotrailsSECRET_KEY_BASE = '<SECRET_KEY>'放在.env文件中,该文件从shared/目录软链接到当前目录的主目录,版本的远程Rails应用程序,并在config.require_master_key = true文件中添加一条语句:config/environments/production.rb

我已将credentials.yml.encmaster.key的文件从本地计算机传输到远程计算机的rails应用程序的shared/config/目录中。另外,我将文件.env放置到远程计算机上的shared/目录中。

我还将文件列表添加到config/deploy.rb的{​​{1}}:
linked_files

我试图将第二个Rails 5.2.0应用程序部署到远程机器,但是它仍然可以部署,并且无法通过浏览器视图工作。我希望有人可以解决这种情况。谢谢。

以下是加载Rails应用程序detail message are at my dropbox link时错误消息的一部分:

append :linked_files, "config/database.yml", "config/credentials.yml.enc", "config/master.key", ".env"
set :rvm_custom_path, '/usr/local/rvm'
set :rvm_ruby_version, '2.4.2@blogapp-rails-5.2.0-ruby-2.4.2'

环境变量:



    Error: The application encountered the following error: ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage)
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:206:in `rescue in _decrypt'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:184:in `_decrypt'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:79:in `decrypt'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:42:in `read'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:21:in `read'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:33:in `config'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:38:in `options'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing'
        (erb):12:in `'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/erb.rb:896:in `eval'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/erb.rb:896:in `result'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activestorage-5.2.0/lib/active_storage/engine.rb:81:in `block (2 levels) in '
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `each'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activestorage-5.2.0/app/models/active_storage/blob.rb:206:in `'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activestorage-5.2.0/app/models/active_storage/blob.rb:16:in `'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:370:in `block in require_or_load'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in `block in load_interlock'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:13:in `loading'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in `load_interlock'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:348:in `require_or_load'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:326:in `depend_on'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `depend_on'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:242:in `require_dependency'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:477:in `each'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:477:in `block in eager_load!'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:475:in `each'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:475:in `eager_load!'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:356:in `eager_load!'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/application/finisher.rb:69:in `each'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/application/finisher.rb:69:in `block in '
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:347:in `each'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:347:in `call'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
        /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
        /var/www/blogApp/releases/20180805160423/config/environment.rb:5:in `'
        config.ru:3:in `require_relative'
        config.ru:3:in `block in '
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `instance_eval'
        /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `initialize'
        config.ru:1:in `new'
        config.ru:1:in `'
        /usr/share/passenger/helper-scripts/rack-preloader.rb:101:in `eval'
        /usr/share/passenger/helper-scripts/rack-preloader.rb:101:in `preload_app'
        /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in '
        /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:380:in `run_block_and_record_step_progress'
        /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `'
        /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `'
        /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `'

激活的宝石:



    APACHE_PID_FILE = /var/run/apache2/apache2.pid
    rvm_bin_path = /usr/share/rvm/bin
    PASSENGER_SPAWN_WORK_DIR = /tmp/passenger.spawn.XXXX5nnkfO
    GEM_HOME = /var/www/blogApp/shared/bundle/ruby/2.4.0
    SSL_TLS_SNI = yhblog.csie.io
    APACHE_RUN_USER = www-data
    SHELL = /bin/bash
    IRBRC = /usr/share/rvm/rubies/ruby-2.4.2/.irbrc
    PYTHONUNBUFFERED = 1
    MY_RUBY_HOME = /usr/share/rvm/rubies/ruby-2.4.2
    USER = xxxxuser
    HTTPS = on
    _system_type = Linux
    rvm_path = /usr/share/rvm
    IN_PASSENGER = 1
    RACK_ENV = production
    PASSENGER_USE_FEEDBACK_FD = true
    rvm_prefix = /usr/share
    APACHE_LOG_DIR = /var/log/apache2
    PATH = /var/www/blogApp/shared/bundle/ruby/2.4.0/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2@rails5.2.0/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2@global/bin:/usr/share/rvm/rubies/ruby-2.4.2/bin:/usr/local/rvm/bin:/home/xxxxuser/.rvm/wrappers/ruby-2.4.2@rails5.2.0/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2/bin:/usr/share/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    WSGI_ENV = production
    PWD = /var/www/blogApp/current
    APACHE_RUN_GROUP = www-data
    LANG = C
    NODE_PATH = /usr/share/passenger/node
    _system_arch = x86_64
    NODE_ENV = production
    _system_version = 14.04
    rvm_version = 1.29.4 (manual)
    HOME = /home/xxxxuser
    SHLVL = 0
    RAILS_ENV = production
    rvm_ruby_string = ruby-2.4.2
    SERVER_SOFTWARE = Apache/2.4.7 (Ubuntu) Phusion_Passenger/5.3.3
    LOGNAME = xxxxuser
    GEM_PATH = 
    PASSENGER_APP_ENV = production
    rvmsudo_secure_path = 1
    rvm_delete_flag = 0
    APACHE_LOCK_DIR = /var/lock/apache2
    APACHE_RUN_DIR = /var/run/apache2
    RUBY_VERSION = ruby-2.4.2
    _system_name = Ubuntu
    rvm_silence_path_mismatch_check_flag = 1
    BUNDLER_ORIG_BUNDLE_BIN_PATH = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLER_ORIG_BUNDLE_GEMFILE = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLER_ORIG_BUNDLER_ORIG_MANPATH = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLER_ORIG_BUNDLER_VERSION = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLER_ORIG_GEM_HOME = /home/xxxxuser/.rvm/gems/ruby-2.4.2@rails5.2.0
    BUNDLER_ORIG_GEM_PATH = /home/xxxxuser/.rvm/gems/ruby-2.4.2@rails5.2.0:/home/xxxxuser/.rvm/gems/ruby-2.4.2@global
    BUNDLER_ORIG_MANPATH = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLER_ORIG_PATH = /home/xxxxuser/.rvm/gems/ruby-2.4.2@rails5.2.0/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2@global/bin:/usr/share/rvm/rubies/ruby-2.4.2/bin:/usr/local/rvm/bin:/home/xxxxuser/.rvm/wrappers/ruby-2.4.2@rails5.2.0/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2@global/bin:/usr/share/rvm/rubies/ruby-2.4.2/bin:/usr/share/rvm/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2/bin:/home/xxxxuser/.rvm/gems/ruby-2.4.2@global/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    BUNDLER_ORIG_RB_USER_INSTALL = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLER_ORIG_RUBYLIB = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLER_ORIG_RUBYOPT = BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL
    BUNDLE_BIN_PATH = /home/xxxxuser/.rvm/gems/ruby-2.4.2@global/gems/bundler-1.16.3/exe/bundle
    BUNDLE_GEMFILE = /var/www/blogApp/releases/20180805160423/Gemfile
    BUNDLER_VERSION = 1.16.3
    RUBYOPT = -rbundler/setup
    RUBYLIB = /usr/share/rvm/rubies/ruby-2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.3/lib
    SECRET_KEY_BASE = 6e6b750cfcd6dd788a29cf7fd9a2d8722e207d3f2f0e90eec5a72e318ba719386126ee3513d53e3b3727057213b3aa9c43a96b08f62de0df1c0def9a9202f72b
    RAILS_MASTER_KEY = 25a3611d36b773ca1b03277a02cf43f8

1 个答案:

答案 0 :(得分:0)

经过研究,我承认我的答案甚至都没有,而且是错误的。我猜这个键必须设置。什么secrets.yml包含?也许您的第二个应用尝试使用第一个应用的机密