Rails,post-部署到 Heroku:无法 运行 控制台,db:migrate

Rails, post-deploy to Heroku: unable to run console, db:migrate

美好的一天,

我和我的团队正在尝试将我们的 Rails 应用程序推送到 Heroku - git push heroku dev:master 成功,但此后 heroku run rails db:migrateheroku run rails console 等都失败了以下错误(完整跟踪粘贴在 post 的底部):

   NoMethodError: undefined method `map' for nil:NilClass
    /app/vendor/bundle/ruby/2.4.0/gems/warden-jwt_auth-0.3.6/lib/warden/jwt_auth.rb:89:in `upcase_first_items'

我在 gem jwt_auth 的文件中找到了失败的方法 upcase_first_items,但仍然无法解决这个问题。搜索 Google 上的错误(包括错误的迭代)出现 0 个结果。

两周前我们成功地将这个应用程序推送到 Heroku,并且此后没有更改任何关于身份验证的内容(我通过审查我们的所有提交来确保这一点最近 2 周)。

有什么想法吗?

谢谢, 迈克尔

完整跟踪:

[cocomio-languages (dev)]$ heroku run rails db:migrate --trace
Running rails db:migrate --trace on ⬢ coco-sprint-3... up, run.2956 (Hobby)
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
rails aborted!
NoMethodError: undefined method `map' for nil:NilClass
/app/vendor/bundle/ruby/2.4.0/gems/warden-jwt_auth-0.3.6/lib/warden/jwt_auth.rb:89:in `upcase_first_items'
/app/vendor/bundle/ruby/2.4.0/gems/warden-jwt_auth-0.3.6/lib/warden/jwt_auth.rb:50:in `block in <module:JWTAuth>'
/app/vendor/bundle/ruby/2.4.0/gems/dry-configurable-0.11.1/lib/dry/configurable/setting.rb:119:in `evaluate'
/app/vendor/bundle/ruby/2.4.0/gems/dry-configurable-0.11.1/lib/dry/configurable/setting.rb:70:in `value'
/app/vendor/bundle/ruby/2.4.0/gems/dry-configurable-0.11.1/lib/dry/configurable/config.rb:111:in `method_missing'
/app/vendor/bundle/ruby/2.4.0/gems/devise-jwt-0.5.9/lib/devise/jwt/railtie.rb:19:in `block (3 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/2.4.0/gems/dry-configurable-0.11.1/lib/dry/configurable/methods.rb:15:in `configure'
/app/vendor/bundle/ruby/2.4.0/gems/devise-jwt-0.5.9/lib/devise/jwt/railtie.rb:15:in `block (2 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `instance_exec'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `run'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:347:in `each'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:347:in `call'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:60:in `run_initializers'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/application.rb:361:in `initialize!'
/app/config/environment.rb:5:in `<main>'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/application.rb:337:in `require_environment!'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `each'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `each'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.4.4/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/app/vendor/bundle/ruby/2.4.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/command.rb:48:in `invoke'
/app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.4.1/lib/rails/commands.rb:18:in `<main>'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/app/bin/rails:4:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment

更新 1

我恢复了前两周(即从现在到最后一次工作部署之间)的每次提交,并进行了部署,但收到了同样的错误。我什至在 before 最后一次部署(正在运行的部署)就已经提交了,但仍然有同样的错误,这让我相信它与我们上次的提交无关几个星期。

当我转到 Heroku 仪表板并将构建从两周前恢复到部署时,Rails 命令(heroku 运行 rails c,heroku 运行 rails db:migrate, 等)再次工作。

devise-jwt0.8.0 版本不再是问题。请在升级时查看版本 0.7.0 中的重大更改。


上一个回答

可能有人或某事将 dry-configurable gem 从版本 0.9.0 升级到 0.11.1。这个 gem 是 warden-jwt_auth 的依赖,它是 devise-jwt 的依赖,新版本打破了它。

前几天发布了dry-configurable的版本0.11.0warden-jwt_auth使用了它,因为它用~> 0.6指定了这个依赖的版本,其中包括错误的版本(从 0.61.0 的一切都可以)。您可以在 Gemfile.lock 或 warden-jwt_auth.

的依赖项中看到

如果有人这样做 运行 bundle upgrade 它将提取新的错误版本。

我建议您将 dry-configurable 的旧版本固定在您的 Gemfile:

gem 'dry-configurable', '0.9.0'

然后 运行 bundle update 并再次部署。