Rails,部署到 Heroku 后:无法运行控制台,db:migrate [英] Rails, post-deploy to Heroku: unable to run console, db:migrate

查看:13
本文介绍了Rails,部署到 Heroku 后:无法运行控制台,db:migrate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早安,

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

My team and I are trying to push our Rails app to Heroku - git push heroku dev:master is successful, but thereafter heroku run rails db:migrate, heroku run rails console, etc. all fail with the following error (full trace pasted at bottom of 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 个结果.

I tracked down the failing method upcase_first_items in the files of the gem jwt_auth, but remain unable to solve this. Searching the error on Google (including iterations of the error) turns up 0 results.

我们在两周前成功将此应用推送到 Heroku,此后在身份验证方面没有任何更改(我通过查看过去 2 周的所有提交确认了这一点).

We successfully pushed this app to Heroku two weeks ago, and have not since changed anything with regards to authentication (which I've made sure of by reviewing all our commits from the last 2 weeks).

有什么想法吗?

谢谢,迈克尔

完整的跟踪:

[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

我恢复到前两周的每个提交(即从现在到最后一次工作部署之间),并部署,但收到相同的错误.我什至从最后一次部署(有效的部署)开始提交,但仍然有同样的错误,这让我相信这与我们过去几周的提交无关.

I reverted to each commit from the previous two weeks (i.e. between now and the last working deploy), and deployed, but received the same error. I reached commits from even before the last deploy (the deploy that was working), and still have the same error, which leads me to believe it has nothing to do with our commits from the last few weeks.

当我访问 Heroku 仪表板并将构建恢复为两周前的部署时,Rails 命令(heroku run rails c、heroku run rails db:migrate 等)再次起作用.

When I went to the Heroku dashboard and reverted the build to the deploy from two weeks ago, the Rails commands (heroku run rails c, heroku run rails db:migrate, etc.) once again work.

推荐答案

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

With the version 0.8.0 of devise-jwt it's no longer a problem. Please see the breaking change in version 0.7.0, when upgrading.

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

Probably someone or something upgraded the dry-configurable gem from version 0.9.0 to 0.11.1. This gem is a dependency of warden-jwt_auth which is a dependency of devise-jwt and the new version breaks it.

几天前的版本0.11.0 of dry-configurable 被释放,warden-jwt_auth 使用它,因为它用 ~> 指定了这个依赖的版本;0.6,包括错误版本(从 0.61.0 都可以).您可以在 Gemfile.lock 或 warden-jwt_auth 的依赖项中看到这一点.

A few days ago the version 0.11.0 of dry-configurable was released and warden-jwt_auth uses it, because it specifies the version of this dependency with ~> 0.6, which includes the faulty version (everything from 0.6 to 1.0 would be fine). You can see that in the Gemfile.lock or in the dependencies of warden-jwt_auth.

如果有人确实运行了 bundle upgrade,它将拉取新的错误版本.

If somebody did run bundle upgrade it will have pulled the new faulty version.

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

I recommend you to pin the older version of dry-configurable in your Gemfile:

gem 'dry-configurable', '0.9.0'

然后运行 ​​bundle update 并再次部署.

Then run bundle update and deploy again.

这篇关于Rails,部署到 Heroku 后:无法运行控制台,db:migrate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆