Heroku错误:“密钥必须为16个字节”,但我输入的密钥为16个字节

时间:2019-04-25 21:29:56

标签: ruby-on-rails ruby heroku

我是第一次启动Heroku,并且收到错误消息“ ArgumentError:密钥必须为16个字节”。

我已经运行rails credentials:edit来生成一个新密钥,得到的密钥是32个字符,运行了heroku config:set RAILS_MASTER_KEY='<master key>'并被接受。但是我运行它时仍然收到错误。

我不确定自己在做什么错。

这是完整的错误消息:

Running: rake assets:precompile
       rake aborted!
       ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:206:in `rescue in _decrypt'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:183:in `_decrypt'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:79:in `decrypt'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:42:in `read'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:21:in `read'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:33:in `config'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:38:in `options'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:24:in `key_exists?'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:10:in `find'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails.rb:37:in `block in <class:Engine>'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
       /tmp/build_e151bdf198daf12c42102939c20b0959/config/environment.rb:7:in `<top (required)>'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'

       Caused by:
       ArgumentError: key must be 16 bytes
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:193:in `key='
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:193:in `_decrypt'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:79:in `decrypt'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:42:in `read'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:21:in `read'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:33:in `config'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:38:in `options'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:24:in `key_exists?'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:10:in `find'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails.rb:37:in `block in <class:Engine>'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
       /tmp/build_e151bdf198daf12c42102939c20b0959/config/environment.rb:7:in `<top (required)>'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
       /tmp/build_e151bdf198daf12c42102939c20b0959/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
       Tasks: TOP => environment
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

1 个答案:

答案 0 :(得分:0)

最初,主键配置设置命令周围有引号,例如:#!/bin/ksh # ... export JAVA_HOME=/path/to/java_jdk # ... ,Heroku将其解释为主键的一部分。

为了后代,我将保留在注释中找到的正确格式的命令:

'<master key>'
相关问题