Error installing mysql2: Failed to build gem native extension

后端 未结 27 2682
清酒与你
清酒与你 2020-11-22 08:06

I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysq

相关标签:
27条回答
  • 2020-11-22 08:44

    This solved my problem once in Windows:

    subst X: "C:\Program files\MySQL\MySQL Server 5.5" 
    gem install mysql2 -v 0.x.x --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib\opt 
    subst X: /D
    
    0 讨论(0)
  • 2020-11-22 08:45

    Have you tried using

     gem install mysql -- --with-mysql-lib=/usr/lib/mysql/lib 
    

    to specify the location of thebase directory as well as the path to the MySQL libraries that are necessary to complete the gem installation?

    Sources: MySQL Gem Install ERROR: Failed to build gem native extension MySQL Forums :: Ruby :: Help needed with installing MySQL binding for Ruby

    0 讨论(0)
  • 2020-11-22 08:45

    You are getting this problem because you have not install MySql. Before install mysql2 gem. Install MySQL. After that mysql2 gem will install.

    0 讨论(0)
  • 2020-11-22 08:48

    You have to Install some dependencies

    sudo apt-get install libmysql-ruby libmysqlclient-dev
    
    0 讨论(0)
  • 2020-11-22 08:48

    I got the gem built on Mac OS X 10.6.6 by 1) Ensuring the Developer tools package is installed 2) Downloading the current MySQL package (5.5.8 in my case) from Source 3) Installing the cmake tool from cmake.org 4) Following the instructions in section 2.11 of INSTALL-SOURCE from the mysql distribution files 5) sudo gem install mysql2 -- --srcdir=/usr/local/mysql/include The gem built successfully, but there are two errors in the documentation that rdoc and ri complain about. But now when I try to require 'mysql2' I get a

    LoadError: no such file to load -- mysql2/mysql2
    

    I was hoping the error I would get was that the libmysqlclient.16.dylib couldn't be found because we figured that out in another post (search for install_name_tool).

    My $PATH has /usr/local/mysql in it (that's where my source and built files are located), so I'm a little stumped. If anyone has any thoughts, I'll check back after a few hours of sleep.

    0 讨论(0)
  • 2020-11-22 08:51

    On Debian Stretch the package that worked for me was default-libmysqlclient-dev

    sudo apt-get update && apt-get install -y default-libmysqlclient-dev

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