Skip to content

Instantly share code, notes, and snippets.

@stillsheryl
Last active January 18, 2024 12:52
Show Gist options
  • Save stillsheryl/7521531f07f185f5cc5eb7bfbada9fa2 to your computer and use it in GitHub Desktop.
Save stillsheryl/7521531f07f185f5cc5eb7bfbada9fa2 to your computer and use it in GitHub Desktop.
OAuth Bundle Update Bug

Fixing an OmniAuth Error: uninitialized constant AuthController

I recently came across a bug when working on a team project that uses Google OmniAuth for authentication. A few different people had the same code on our local machines, and only one person was receiving an error, which was the following Google OAuth error:

Failures:
 1) welcome page As an authenticated users user logs in using Google OAuth
   Failure/Error: click_link 'Log In with Google'
   ActionController::RoutingError:
    uninitialized constant AuthController
   # ./spec/features/welcome/landing_spec.rb:34:in `block (4 levels) in <top (required)>'
   # ./spec/features/welcome/landing_spec.rb:33:in `block (3 levels) in <top (required)>'
   # ------------------
   # --- Caused by: ---
   # NameError:
   #  uninitialized constant AuthController
   #  ./spec/features/welcome/landing_spec.rb:34:in `block (4 levels) in <top (required)>'

After much looking around, we found the source of the bug to be a version update from a bundle update command made along the way. This had caused the version of omniauth to be updated from version 1.9 to version 2.0, which broke the OmniAuth connection. You can read more about the changes with Version 2.0 of OmniAuth here, and it mentions that some changes may be breaking depending on how you use OmniAuth in your app.

To fix the issue we updated our Gemfile by specifying the version of OmniAuth we wanted to use.

omniauth gemfile

A big takeaway for me from this was to be especially careful when adding gems, and be mindful when using the bundle update command, because it may change more than you expect.

The way I found the error was by closely reviewing the Pull Request and noticing the difference between the omniauth versions in the Gemfile.

@dil-atiwari
Copy link

@stillsheryl Have you found any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment