Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Error installing mysql2: Failed to build gem native extension

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.09k
    Comment on it

    This error used to come when you are trying to do bundle install and mysql2 gem is unable to install properly. So below are the steps as per the different operating systems:

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

    Step 1: sudo gem update --system
    
    Step 2: sudo apt-get install build-essential
    

    After these two steps you have to install libmysqlclient-devel:

    CentOS/Fedora:

    yum install -y libmysqlclient-devel
    

    Ubuntu:

    apt-get install -y libmysqlclient-dev
    

    Mac:

    brew install mysql
    

    Windows:

    gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'
    

    Now the gem should have installed correctly

    At Last copy the libmysql.dll file from

    C:\Program Files\MySQL\MySQL Server 5.5\lib
    

    to

    C:\Rails\Ruby1.9.2\bin
    

    Hope it helps.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: