Rails 服务器在 omniauth 更新后停止 运行(破坏设计)

Rails server stopped running after omniauth update (breaks devise)

我遵循了从分支到主控(设计)的拉取请求,但我仍然遇到错误,我无法再将 api 部署到服务器

我也尝试了这个问题提供的解决方案,但没有成功:

错误:

/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `<top (required)>': You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed. (RuntimeError)

本地主机上的错误相同

Ruby版本:2.5.1p57

rails (5.1.7)

设计 (4.7.3)

omniauth (2.0.1)

omniauth-facebook (8.0.0)

omniauth-oauth2 (1.7.1)

我认为 this commit 解决了您遇到的问题,不幸的是它不会通过 bundle update 自动拉入您的项目,直到设计更新他们的版本。

所以我认为您可以使用 gem 'devise', github: 'heartcombo/devise' 在 Gemfile 中修复此问题(您可能需要先卸载原始版本)

并且您可以使用 bundle show devise 来验证新 gem 的位置,转到 lib/devise/omniauth.rb,并确保它以以下内容打开:

# PATH_TO_DEVISE_GEM/lib/devise/omniauth.rb

# frozen_string_literal: true

begin
  gem "omniauth", ">= 1.0.0"

  require "omniauth"
rescue LoadError
  warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
  raise
end

当我昨天 运行 遇到这个完全相同的问题时,我的版本如下,这就是它为我打破它的原因:

# PATH_TO_OLD_DEVISE_GEM/lib/devise/omniauth.rb

[...]
unless OmniAuth::VERSION =~ /^1\./  if Gem::Version.new(OmniAuth::VERSION) < Gem::Version.new('1.0.0')
  raise "You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed."     raise "You are using an old OmniAuth version, please ensure you have 1.0.0 version or later installed."
end
[...]

devise 更新到最新版本(当前为 4.8.0)应该可以解决问题。我可以确认它在我的案例中是这样做的。

此处有更多信息:https://github.com/heartcombo/devise/commit/1d138dd40cdc291a427b89027d16a869818a5c19#commitcomment-50168476