Gem::LoadError for mysql2 gem, but it's already in Gemfile

后端 未结 14 2648
醉酒成梦
醉酒成梦 2020-12-02 08:35
Gem::LoadError
Specified \'mysql2\' for database adapter, but the gem is not loaded.
Add `gem \'mysql2\'` to your Gemfile

This error occurred while

14条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 09:00

    It worked for me when I specified a mysql2 gem version before the newest one (0.4.0). For some reason there is a problem with Rails 4.2.4 and that gem 0.4.0. So, to solve the problem I just specified the previous gem released: 0.3.20 and it worked fine for me!

    gem 'mysql2', '~> 0.3.20'
    bundle install
    

    You can check all the gems versions here: https://rubygems.org/gems/mysql2/versions

提交回复
热议问题