ruby-on-rails - Heroku 错误:“密钥必须是 16 个字节”,但我输入的密钥是 16 个字节
问题描述
我第一次启动 Heroku,我收到错误“ArgumentError: key must be 16 bytes”。
我已经运行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
解决方案
最初,master key configuration set 命令周围有引号,如下所示:'<master key>'
Heroku 将其解释为 master key 的一部分。
只是为了后代,我将留下我们在评论中发现的正确格式的命令:
$ heroku config:set RAILS_MASTER_KEY=<master key>
推荐阅读
- assembly - 加法大于 15 时 x86 程序集错误中的解压缩十进制格式
- ios - 定时器循环 - 不是 NSTimer - Swift
- windows - windows server 2016如何创建子域
- python - 如何编写适用于 Python 2 和 Python 3 的代码?
- java - 未找到可绘制资源
- graph - 如何编码/探索 DAG 的多个线性排序
- r - plot3d() - 如何将 z 轴表面颜色更改为热图颜色
- html - 需要汉堡移动菜单图标而不是文本
- haskell - 在 Haskell Stack 项目中构建 yesod/amazonka 依赖项时遇到问题
- javascript - POST 请求后,子组件不会重新渲染父组件