ERROR: Failed to build gem native extension - Error installing mysql2

前端 未结 5 551
北恋
北恋 2021-02-02 06:22

error while running bundle install

Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native exte         


        
相关标签:
5条回答
  • 2021-02-02 06:50

    Try to install these packages:

    sudo apt-get install libmysqlclient-dev
    
    sudo apt-get install bundler 
    

    After installing the bundler, run:

    gem install mysql2
    
    0 讨论(0)
  • 2021-02-02 06:54

    This thread helped in installing mysql2

    Github thread on installing mysql2 on OSX Mojave

    as mentioned in the thread I tried

    $ bundle config build.mysql2 --with-opt-dir=/usr/local/opt/openssl
    
    0 讨论(0)
  • 2021-02-02 07:02

    Sometimes you need to update your Ruby library, run this code:

    sudo gem update --system
    
    0 讨论(0)
  • 2021-02-02 07:03

    which OS are you using?

    anyway if you are using ubuntu, from this https://github.com/brianmario/mysql2/issues/8 run:

    sudo apt-get install mysql-client libmysqlclient-dev
    

    Otherwise for Mac users,(use brew to install) check this http://mxcl.github.com/homebrew/, or run:

    brew install mysql
    

    then

    sudo gem install mysql2
    

    and for windows users check the link below for a solution. Error installing mysql2: Failed to build gem native extension

    I would recommend to use the normal command prompt.

    0 讨论(0)
  • 2021-02-02 07:04

    If the stack trace includes this error:

    mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
    

    Look at what version of ruby you're using with:

    ruby -v
    

    Then install the correct version of ruby dev that goes with your version of ruby:

    sudo apt-get install ruby2.0-dev
    sudo apt-get install ruby2.2-dev
    sudo apt-get install ruby2.3-dev
    

    Then:

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