mysql2: "Specified 'mysql2' for database adapter, but the gem is not loaded" when upgrading to 0.5.0

I just tried upgrading from 0.4.10 to 0.5.0 in a Rails app and got the following error when starting the server in development:

=> Booting Puma
=> Rails 5.1.5 application starting in development 
=> Run `rails server -h` for more startup options
Exiting
Traceback (most recent call last):
   ....
   5: from /home/dev/.rvm/gems/ruby-2.5.0/gems/activesupport-5.1.5/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
   4: from /home/dev/.rvm/gems/ruby-2.5.0/gems/activerecord-5.1.5/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
   3: from /home/dev/.rvm/gems/ruby-2.5.0/gems/activerecord-5.1.5/lib/active_record/connection_handling.rb:58:in `establish_connection'
   2: from /home/dev/.rvm/gems/ruby-2.5.0/gems/activerecord-5.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
   1: from /home/dev/.rvm/gems/ruby-2.5.0/gems/activerecord-5.1.5/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec'
/home/dev/.rvm/gems/ruby-2.5.0/gems/activerecord-5.1.5/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)

I simply changed the version in the Gemfile to 0.5.0 and rebundled. If I downgrade to 0.4.10, everything works fine.

I’m using:

Ruby: 2.5.0 Rails: 5.15 Ubuntu: 16.04 mysql: mysql Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19

Commits related to this issue

Most upvoted comments

This is expected until the next minor revisions of Rails that enable mysql2 0.5.0 to load.

For Rails 4.x please pin the gem to mysql2 '~> 0.4.0' to avoid the 0.5.x upgrade.

For Rails 5.x the next point releases will enable both mysql2 0.4.x and 0.5.x.

Rails 5.0.7 and 5.1.6 have been released with support for mysql2 0.5.x.

Rails 4.x will not be updated to allow mysql2 0.5.x, simply because it is outside of its feature update maintenance window. As a matter of functionality, it would work fine together, but as a matter of being community supported it is not.

For Rails 4.x please pin the gem to mysql2 ā€˜~> 0.4.0’ to avoid the 0.5.x upgrade.

For Rails 5.x the next point releases will enable both mysql2 0.4.x and 0.5.x.

Until the next 5.x point release, you should pin the mysql2 gem to 0.4.x as well. It will probably be a few weeks until the next point releases.