Skip to content

Commit

Permalink
Simplify OmniAuth version check by trying to load the gem with the ne…
Browse files Browse the repository at this point in the history
…cessary version
  • Loading branch information
carlosantoniodasilva committed Jan 22, 2021
1 parent c43ae8c commit 1d138dd
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/devise/omniauth.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# frozen_string_literal: true

begin
gem "omniauth", ">= 1.0.0"

require "omniauth"
require "omniauth/version"
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

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 version or later installed."
end

# Clean up the default path_prefix. It will be automatically set by Devise.
OmniAuth.config.path_prefix = nil

Expand Down

10 comments on commit 1d138dd

@yshmarov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using

    devise (4.7.3)
    omniauth (2.0.2)

I still get this error

/home/ubuntu/.rvm/gems/ruby-2.7.2/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `<main>': You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed. (RuntimeError)

@yshmarov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol I was using the last release of devise from September.
To make it work:

# gem "devise"
gem "devise", github: "heartcombo/devise", branch: "master"

@carlosantoniodasilva
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yshmarov correct, we don't have a new release yet containing these changes for OmniAuth. :) Hopefully it all works well with master.

@yshmarov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work well with master

@adamlutz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pegging the version to master works for me as well.
I couldn't find it, but is there an anticipated date for the next officially tagged release after v4.7.3?

I'm a little nervous pegging a version to the master branch in production since it seems possible it will change on me during builds.
Any recommendations on how to best mitigate any possible issues going this route would be appreciated!

Thanks!

@carlosantoniodasilva
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamlutz when you lock your bundle to master or any branch, it will lock it to a specific commit at that moment in time, and should continue using the same commit going forward. It shouldn't update from under you, unless you remove the lock file or run bundle update.

I'm looking into a possible new release, but have a few other things I want to get included before I can bump it to a 4.8 or something. Hopefully soon.

@adamlutz
Copy link

@adamlutz adamlutz commented on 1d138dd Apr 2, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlosantoniodasilva
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed v4.8 including this change, please give it a try and report back if you have any issues. Thanks.

@kurko
Copy link

@kurko kurko commented on 1d138dd May 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: the error is gone after bundle update devise.

@ajayKomirishetty
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like upgrading devise gem working in local environment, but on deployment build seems to be failing with the following reason

Error: buildx failed with: error: failed to solve: executor failed running [/bin/sh -c gem install bundler --no-document && bundle config --local path $BUNDLE_PATH && bundle config set without 'profile development test' && bundle config set deployment 'true' && bundle install -j $(nproc)]: exit code: 16
not sure what other steps are we supposed to do for this issue?

gem 'omniauth', '~> 2.0.2'
and devise gem version is 4.8.1

Please sign in to comment.