Error installing Mysql2 gem- 10.6 Server

不问归期 提交于 2019-12-10 09:35:38

问题


I'm trying to install the mysql2 gem on 10.6 server and I get an error message I haven't seen:

EBuilding 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.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.
-----
*** 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


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

I've tried a couple things, specifying where the built-in MySQL is stored sudo gem install mysql2 -- --with-mysql-dir=/var/mysql and also replacing the built-in mysql with the pre-built 64-bit installer from mysql.com

Any ideas?


回答1:


Figured it out:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config



回答2:


I found out you have to have the package mysql-devel installed ... On Centos do yum -y install mysql-devel and you're good to go.




回答3:


I have the same problem on OSX 10.5 with RVM with the "system" Ruby interpreter. Using Ruby 1.8.7 through RVM fixed the situation.

I was inspired by: https://gist.github.com/440334#file_gistfile1.txt



来源:https://stackoverflow.com/questions/4424581/error-installing-mysql2-gem-10-6-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!