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
- Lock mysql2 version to 0.4.x Rails is not ready for version 0.5, see https://github.com/brianmario/mysql2/issues/950#issuecomment-375156196 — committed to solidusio/solidus_i18n by alepore 6 years ago
- Lock 'mysql2' version to 0.4 Version 0.5.0 has just been released and will get loaded by default, however this is not yet supported by any version of Rails as per this issue https://github.com/brianm... — committed to solidusio-contrib/solidus_active_shipping by forkata 6 years ago
- Limit mysql2 version to avoid bug: https://github.com/brianmario/mysql2/issues/950 — committed to instana/ruby-sensor by pglombardo 6 years ago
- Limit mysql2 version to avoid bug: https://github.com/brianmario/mysql2/issues/950 — committed to instana/ruby-sensor by pglombardo 6 years ago
- Pin mysql2 version Otherwise mysql2 will upgrade to v0.5 (when we `bundle update`), which doesn't work with Rails 4.x See https://github.com/brianmario/mysql2/issues/950 (This should be unpinned afte... — committed to JoeCohen/mushroom-observer by JoeCohen 6 years ago
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.
It looks like mysql2 0.5.x is now supported with the 4.2.11 release.
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.