I can't run “bundle update” because of “mysql2” gem

后端 未结 5 1720
庸人自扰
庸人自扰 2021-02-14 14:29

I have this in the Gemfile:

gem \'mysql2\'

But when I run bundle update, I get this error message:

An error oc         


        
相关标签:
5条回答
  • 2021-02-14 14:36

    I just installed mysql via $ brew install mysql and it fixed the problem.

    0 讨论(0)
  • 2021-02-14 14:38

    I've ended up with a near-identical error message from attempting to build on a machine without gcc-c++ installed; mkmf is failing to compile a simple c program because the compiler flat out isn't there.

    If you're on CentOS, you want sudo yum install gcc-c++. On Ubuntu, it's sudo apt-get install g++. It's a little disappointing that old versions of ruby-devel don't have a dependency on g++.

    0 讨论(0)
  • 2021-02-14 14:50

    On Ubuntu, run

    sudo apt-get install libmysqlclient-dev
    

    Or, if you use MariaDB, run

    sudo apt-get install libmariadbclient-dev
    
    0 讨论(0)
  • 2021-02-14 14:52

    Add this in Gemfile:-

    gem 'mysql2', '0.3.16'
    

    Then:-

    bundle install
    

    After that try:-

    bundle update
    
    0 讨论(0)
  • 2021-02-14 14:54

    Looks like there is no mysql2 gem installed in your machine.As you are using Mac OSX,you should be installing mysql2 gem like this

    gem install mysql2 -- --with-mysql-dir=/usr/local/opt/mysql/ 
    

    If the above command did't work,try like this

    sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
    

    And after try

    bundle install
    

    This should fix the error.

    Source

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