[英]Can't get mysql2 gem to install. Install can't find mysql.h
I am trying to install mysql2: 我正在尝试安装mysql2:
sudo gem install mysql2 -v '0.2.7' -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.25a/bin/mysql_config
I'm getting this error: 我收到此错误:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb -- with-mysql-config=/usr/local/Cellar/mysql/5.5.25a/bin/mysql_config
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.
my mysql install is via brew so my mysql.h file is located at: 我的mysql安装是通过brew进行的,因此我的mysql.h文件位于:
/usr/local/Cellar/mysql/5.5.25a/bin/mysql_config
which is why I have the with-mysql-config flag 这就是为什么我有with-mysql-config标志
The mysql_config file is looking for the mysql.h file here: mysql_config文件在这里寻找mysql.h文件:
$basedir/include/mysql/mysql.h
it should be added that I updated my gemfile from 应该补充一点,我从更新了我的gemfile
gem 'mysql2 gem'mysql2
to gem 'mysql2', '0.2.7' 宝石'mysql2','0.2.7'
because, I was getting some deprecation warning about the fact that mysql2 0.3.* didn't have active record support. 因为,关于mysql2 0.3。*没有活动记录支持的事实,我收到了一些过时的警告。 So would either have to upgrade rails to 3.1 or downgrade mysql2.
因此,要么将Rails升级到3.1,要么降级mysql2。 I chose the latter.
我选择了后者。
Should I edit the mysql_config or is there something else I can do to fix this? 我应该编辑mysql_config还是可以做些其他的事情来解决这个问题? Thanks for any help.
谢谢你的帮助。
I realise this is an old question but for anyone coming here from google I found this solution worked for me: http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html . 我意识到这是一个老问题,但是对于任何来自google的人来说,我发现此解决方案都对我有用: http : //www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os。 html 。
The short version is to remove compiler flags -Wno-null-conversion -Wno-unused-private-field
from /usr/local/Cellar/mysql/5.6.12/bin/mysql_config
around line 120 (replace mysql version with whatever you have to find the file). 简短的版本是从
/usr/local/Cellar/mysql/5.6.12/bin/mysql_config
删除第120行附近的编译器标志-Wno-null-conversion -Wno-unused-private-field
(用您拥有的所有版本替换mysql版本查找文件)。
I'm on OSX with homebrew mysql and rvm using ruby 1.9.3. 我在OSX上使用ruby 1.9.3,使用自制的mysql和rvm。
您应该安装mysql-dev
软件包,这是一些用于编译本机驱动程序的头文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.