ruby-on-railsdeviserubygemsomniauthomniauth-facebook

Rails server stopped running after omniauth update (breaks devise)


I followed the pull request from the branch to the master (devise) but I'm still having the error and I can't deploy the api to the server anymore

I also tried the solutions provided in this question but was not successful:

Latest omniauth-facebook gem breaks devise

The error:

/.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)

the error is the same on localhost

Ruby version: 2.5.1p57

rails (5.1.7)

devise (4.7.3)

omniauth (2.0.1)

omniauth-facebook (8.0.0)

omniauth-oauth2 (1.7.1)


Solution

  • I think this commit fixes the issue you are seeing, unfortunately it will not automatically be pulled into your project through bundle update until devise bumps their version.

    So I think you can fix this in the Gemfile with gem 'devise', github: 'heartcombo/devise' (you may need to uninstall the original version first)

    And you can verify by using bundle show devise to reveal where the new gem is, go to lib/devise/omniauth.rb, and make sure it opens with the following:

    # 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
    

    What my version had when I ran into this exact same problem yesterday was the following, and this is why it was breaking it for me:

    # 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
    [...]