首页 > 解决方案 > Rails 5.2.0 加载应用程序错误:ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage

问题描述

我已经尝试了解决方案,这些解决方案发布在以下链接:
Rails 5.2 with master.key Digital Ocean deployment: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage Rails Deploy Digitalocean ActiveSupport::MessageEncryptor::InvalidMessage: Getting error in尝试部署 Rails 5.2.0 App 时记录 ActiveSupport::MessageEncryptor::InvalidMessage

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

我的环境是:

  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. 这个是可部署的,但不能通过浏览器视图进行。我曾经因为错误提交和推送到 git-remote 存储库而master.key重新生成文件。credentials.yml.enc
  4. 它们的两个 gemset 都在同一个 rvm 中,名为:rails5.2.0
  5. capistrano通过和部署rails-capistrano gem
  6. 他们都使用 phusion 乘客 5.3.3 + apache 2.4.7

对于 rails 5.2.0 应用程序的第二个,我使用将gem dotrails文件从目录软链接到当前版本远程 rails 应用程序的主目录,并添加语句:to file。 SECRET_KEY_BASE = '<SECRET_KEY>'.envshared/config.require_master_key = trueconfig/environments/production.rb

我已经将本地机器的文件传输到credentials.yml.enc远程机器的rails应用程序的目录中。另外,我将文件放在远程机器上的目录中。master.keyshared/config/.envshared/

我还将文件列表添加到config/deploy.rb's linked_files
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'

我已经尝试将第二个 rails 5.2.0 应用程序部署到远程机器上,它仍然可以通过浏览器视图进行部署并且无法使用。我希望有人可以解决这种情况。谢谢你。

以下是加载 Rails 应用程序时的错误消息的一部分,详细消息在我的保管箱链接中



    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

激活宝石:



    did_you_mean => 1.1.0
    bundler => 1.16.3
    io-console => 0.4.6
    rake => 12.3.1
    concurrent-ruby => 1.0.5
    i18n => 1.0.1
    minitest => 5.11.3
    thread_safe => 0.3.6
    tzinfo => 1.2.5
    activesupport => 5.2.0
    builder => 3.2.3
    erubi => 1.7.1
    mini_portile2 => 2.3.0
    nokogiri => 1.8.4
    rails-dom-testing => 2.0.3
    crass => 1.0.4
    loofah => 2.2.2
    rails-html-sanitizer => 1.0.4
    actionview => 5.2.0
    rack => 2.0.5
    rack-test => 1.1.0
    actionpack => 5.2.0
    nio4r => 2.3.1
    websocket-extensions => 0.1.3
    websocket-driver => 0.7.0
    actioncable => 5.2.0
    globalid => 0.4.1
    activejob => 5.2.0
    mini_mime => 1.0.0
    mail => 2.7.0
    actionmailer => 5.2.0
    activemodel => 5.2.0
    arel => 9.0.0
    activerecord => 5.2.0
    mimemagic => 0.3.2
    marcel => 0.3.2
    activestorage => 5.2.0
    execjs => 2.7.0
    autoprefixer-rails => 9.0.2
    bcrypt => 3.1.11
    msgpack => 1.2.4
    bootsnap => 1.3.1
    popper_js => 1.14.3
    rb-fsevent => 0.10.3
    ffi => 1.9.25
    rb-inotify => 0.9.10
    sass-listen => 4.0.0
    sass => 3.5.7
    bootstrap => 4.1.3
    coffee-script-source => 1.12.2
    coffee-script => 2.4.1
    method_source => 0.9.0
    thor => 0.20.0
    railties => 5.2.0
    coffee-rails => 4.2.2
    orm_adapter => 0.5.0
    responders => 2.4.0
    warden => 1.2.7
    devise => 4.4.3
    dotenv => 2.3.0
    dotenv-rails => 2.3.0
    multi_json => 1.13.1
    jbuilder => 2.7.0
    jquery-rails => 4.3.3
    kaminari-core => 1.1.1
    kaminari-actionview => 1.1.1
    kaminari-activerecord => 1.1.1
    kaminari => 1.1.1
    pg => 1.0.0
    puma => 3.12.0
    sprockets => 3.7.2
    sprockets-rails => 3.2.1
    rails => 5.2.0
    tilt => 2.0.8
    sass-rails => 5.0.7
    sassc => 1.12.1
    sqlite3 => 1.3.13
    turbolinks-source => 5.1.0
    turbolinks => 5.1.1
    uglifier => 4.1.16

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

解决方案


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


推荐阅读