Gem::LoadError for mysql2 gem, but it's alread

2019-01-10 06:11发布

Gem::LoadError
Specified 'mysql2' for database adapter, but the gem is not loaded.
Add `gem 'mysql2'` to your Gemfile

This error occurred while loading the following files:

active_record/base

This is the error I get on running rails server.

The mysql2 gem has been added to the Gemfile as well.

I've done bundle install, and tried restarting the server but still get the error.

13条回答
仙女界的扛把子
2楼-- · 2019-01-10 07:02

I had the same error and this is because Rails 4.1 requires minimum mysql2 version 0.3.13, and maximum compatible with Windows is version 0.3.11.

So I edited file c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\activerecord-4.1.1\lib\active_record\connection_adapters\mysql2_adapter.rb and changed line gem 'mysql2', '~> 0.3.13' to gem 'mysql2', '~> 0.3.11', and it works so far.

查看更多
登录 后发表回答