New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql2 0.4.0 Gem::LoadError - fix #675

Closed
faramund opened this Issue Sep 8, 2015 · 9 comments

Comments

Projects
None yet
6 participants
@faramund

faramund commented Sep 8, 2015

I updated mysql2 to 0.4.0. Unfortunately I got an error :
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 downgraded the gem to 0.3.20. and everything is fine now. So you have a bug somewhere.

@sodabrew

This comment has been minimized.

Show comment
Hide comment
@sodabrew

sodabrew Sep 8, 2015

Collaborator

This is not enough information. Please check and see if the mysql2 gem built, or you need to update your Gemfile in some way. If you have an error message, posting it will help me know what the error is.

Collaborator

sodabrew commented Sep 8, 2015

This is not enough information. Please check and see if the mysql2 gem built, or you need to update your Gemfile in some way. If you have an error message, posting it will help me know what the error is.

@philipgiuliani

This comment has been minimized.

Show comment
Hide comment
@philipgiuliani

philipgiuliani Sep 8, 2015

I have the same problem. I ran bundle update mysql2 (had 0.3.20 before) and now when i want to run rails c i get the following message:

/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:177: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)

gem "mysql2" is of course in my Gemfile and its also installed. Downgrading fixes the problem again.

philipgiuliani commented Sep 8, 2015

I have the same problem. I ran bundle update mysql2 (had 0.3.20 before) and now when i want to run rails c i get the following message:

/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:177: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)

gem "mysql2" is of course in my Gemfile and its also installed. Downgrading fixes the problem again.

@philipgiuliani

This comment has been minimized.

Show comment
Hide comment
@philipgiuliani

philipgiuliani Sep 8, 2015

Update

Rails has limited the gem to ~> 0.3.18

rails/rails@5da5e37

in master it's now supported.

philipgiuliani commented Sep 8, 2015

Update

Rails has limited the gem to ~> 0.3.18

rails/rails@5da5e37

in master it's now supported.

@sodabrew

This comment has been minimized.

Show comment
Hide comment
@sodabrew

sodabrew Sep 8, 2015

Collaborator

@philipgiuliani Thanks for finding that - because the adapter is calling for ~> 0.3.x (where x has been updated at times for different bug fixes), it will fail to load 0.4.0. This is sure to cause some confusion because Bundler isn't aware of this restriction and will update mysql2 beyond the range supported by AR.

Reported at Rails as well: rails/rails#21544

Collaborator

sodabrew commented Sep 8, 2015

@philipgiuliani Thanks for finding that - because the adapter is calling for ~> 0.3.x (where x has been updated at times for different bug fixes), it will fail to load 0.4.0. This is sure to cause some confusion because Bundler isn't aware of this restriction and will update mysql2 beyond the range supported by AR.

Reported at Rails as well: rails/rails#21544

jhawthorn added a commit to jhawthorn/solidus that referenced this issue Sep 9, 2015

Fix mysql2 version requirement
mysql2 has released version 0.4.0, but ActiveRecord 4.2 requires 0.3.x.
This fixes

  Specified 'mysql2' for database adapter, but the gem is not loaded.

See brianmario/mysql2#675
@kaleemullah360

This comment has been minimized.

Show comment
Hide comment
@kaleemullah360

kaleemullah360 Sep 15, 2015

do
gem 'mysql2', '~> 0.3.18' this gem works with rails version 4.x.x
if install gem 'mysql2', '~> 0.4.0' it produces gem load error

kaleemullah360 commented Sep 15, 2015

do
gem 'mysql2', '~> 0.3.18' this gem works with rails version 4.x.x
if install gem 'mysql2', '~> 0.4.0' it produces gem load error

@nimashariatian

This comment has been minimized.

Show comment
Hide comment
@nimashariatian

nimashariatian Oct 23, 2015

any updates regarding this issue?

nimashariatian commented Oct 23, 2015

any updates regarding this issue?

@sodabrew

This comment has been minimized.

Show comment
Hide comment
@sodabrew

sodabrew Oct 23, 2015

Collaborator

Rails 4.2.5 and above will allow mysql2 versions 0.3.x and 0.4.x at your option.

For older versions of Rails, you'll need to pin mysql2 in your Gemfile, for example:

gem 'rails', '~> 4.1.0'
gem 'mysql2', '~> 0.3.13'
Collaborator

sodabrew commented Oct 23, 2015

Rails 4.2.5 and above will allow mysql2 versions 0.3.x and 0.4.x at your option.

For older versions of Rails, you'll need to pin mysql2 in your Gemfile, for example:

gem 'rails', '~> 4.1.0'
gem 'mysql2', '~> 0.3.13'
@jd159

This comment has been minimized.

Show comment
Hide comment
@jd159

jd159 Nov 12, 2015

How exactly do you pin gem 'mysql2', '~> 0.3.13'??

I'm not sure how to change the version

jd159 commented Nov 12, 2015

How exactly do you pin gem 'mysql2', '~> 0.3.13'??

I'm not sure how to change the version

@sodabrew

This comment has been minimized.

Show comment
Hide comment
@sodabrew

sodabrew Nov 12, 2015

Collaborator

If the project you are working on has a Gemfile, then you'll edit the Gemfile. For more information: http://bundler.io/

Collaborator

sodabrew commented Nov 12, 2015

If the project you are working on has a Gemfile, then you'll edit the Gemfile. For more information: http://bundler.io/

ghost pushed a commit to huggys/lodge that referenced this issue Mar 29, 2016

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