Ruby gem mysql2安装失败
当我尝试安装mysql2 gem时,它失败并没有明显的错误。 有谁知道该怎么做才能解决这个问题,以便mysql2安装?
Tanner-Smiths-MacBook-Pro:Humans_vs_Zombies_Parse tanner$ sudo gem install mysql2Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb checking for rb_thread_blocking_region()... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lmygcc... no checking for mysql_query() in -lmysqlclient... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-mysql-config --without-mysql-config --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysqlclientlib --without-mysqlclientlib --with-mlib --without-mlib --with-mysqlclientlib --without-mysqlclientlib --with-zlib --without-zlib --with-mysqlclientlib --without-mysqlclientlib --with-socketlib --without-socketlib --with-mysqlclientlib --without-mysqlclientlib --with-nsllib --without-nsllib --with-mysqlclientlib --without-mysqlclientlib --with-mygcclib --without-mygcclib --with-mysqlclientlib --without-mysqlclientlib Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
你必须在你的机器上安装64位MySQL,以及你在安装xcode时获得的构建工具。
Ubuntu的:
sudo apt-get install libmysqlclient-dev #(mysql development headers)
sudo gem install mysql2 -- --with-mysql-dir=/etc/mysql/
而已!
结果:
Building native extensions. This could take a while...
Successfully installed mysql2-0.2.6
1 gem installed
Installing ri documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
您需要MySQL2的MySQL开发标头才能正确编译。 这是必要的,因为大部分功能都是用C语言编写的,然后与MySQL连接。
解决方法是将gem安装程序明确指向您的mysql安装文件夹
gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
# or where ever you installed your mysql server to
或者通过安装一个mysql服务器到一个已知的位置(例如使用自制软件),然后安装gem
# install the mysql server locally
brew install mysql
# install the gem
gem install mysql2
这两种方法都需要您安装XCode才能拥有所需的GCC编译器。
链接地址: http://www.djcxy.com/p/33239.html上一篇: Ruby gem mysql2 install failing
下一篇: Gem installation ERROR: Failed to build gem native extension