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

后端 未结 14 2536
醉酒成梦
醉酒成梦 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 08:37

    Here is how I fixed this:

     bundle config
     bundle config --delete without
     bundle install --deployment --without development test postgres
    

    Credits: How do you undo bundle install --without

    0 讨论(0)
  • 2020-12-02 08:42

    I solved the problem, installing the libmysqlclient-dev. sudo aptitude install libmysqlclient-dev and later run bundle.

    0 讨论(0)
  • 2020-12-02 08:45

    Change to

    gem 'mysql2', '~> 0.3.18'
    

    in your Gemfile.

    This thread on the official mysql2 Github says to do this. You need to declare that version number if you're rails version 4.x.x.

    https://github.com/brianmario/mysql2/issues/675

    Then run bundle update mysql2.

    0 讨论(0)
  • 2020-12-02 08:47

    It doesn't load mysql2 gem because new version of mysql2(0.4.1) gem unable to load the mysql2_adaptor. This is working for me.

    gem 'mysql2', '~> 0.3.13'
    

    and run

    bundle install
    
    0 讨论(0)
  • 2020-12-02 08:49

    I'm brand spanking new to Ruby on Rails and websites but hears what worked for me.

    I had to change my gemfile, gem 'mysql2' to gem 'mysql2', '~> 0.3.13' then in rails i typed bundle install then i tried rails s and got errors so then i tried bundle update mysql2 then in rails typed rails s, and it worked

    0 讨论(0)
  • 2020-12-02 08:52

    Being Beginner to the ruby i could not figure out the line gem 'mysql2', '~> 0.3.18'

    it simply means go to your rails project folder and then there is line for mysql2 it will be like 0.4* so you can change it to gem 'mysql2', '~> 0.3.18'

    and as we have new definition, we have to rebuild the dependency so to do that simple command as explained on the top bundle install

    0 讨论(0)
提交回复
热议问题