Search code examples
mysqlruby-on-railsrubybundler

Error loading the 'mysql2' Active Record adapter


I am trying to upgrade my app and this is the error I am getting while deploying the app:

Error loading the 'mysql2' Active Record adapter. Missing a gem it depends on? can't activate mysql2 (< 0.6.0, >= 0.4.4), already activated mysql2-0.3.21. Make sure all dependencies are added to Gemfile.

here is my Gemfile: https://github.com/BI-CTSICN/sparc-request/blob/master/Gemfile

 gem 'mysql2', '~> 0.3.18'
 gem 'rails', '~> 5.1', '>= 5.1.4'

I am using ruby 2.4.2


Solution

  • Your mysql2 version you use (0.3.21, checked in Gemfile.lock) is too old, required one is newer than 0.4.4.

    Upgrade your mysql2 gem by changing version in Gemfile and running bundle update mysql2. Of course before that check what changed between versions and then run your tests to check if upgrade didn't break anything.