一尘不染

通过捆绑器安装mysql2 gem时出错

mysql

我正在尝试mysql2通过Bundler 安装gem,但是它一直死于以下错误:

** executing command
/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb:483:in 'rescue in block in build_extensions': 
ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
checking for rb_thread_blocking_region()... yes
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=/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
--with-mysql-config
Gem files will remain installed for inspection.

我通过谷歌搜索发现的大多数事情都建议传递--with-mysql-config参数来修复它。因此,基于:

$ which mysql_config
/usr/bin/mysql_config

我将以下内容添加到Bundler的配置中:

$ bundle config build.mysql2 --with-mysql-config='/usr/bin/mysql_config'

但是,仍然没有运气-与上述相同。

因为它快死于错误了mysql.h is missing,所以我检查了一下,并且据说它在附近,只是Bundler找不到。

$ find / -name mysql.h
/usr/include/mysql5/mysql/mysql.h

有什么想法吗?


阅读 154

收藏
2020-05-17

共1个答案

一尘不染

答案与Wrikken发布的答案相似-这是我为将来的读者而修复的内容。

(这是针对RHEL 5.5的-类似但不同的命令适用于Ubuntu / Debian / etc。)

这样做sudo yum list installed会打印出您机器上所有已安装的软件包(注意:yum在RHEL 上,您需要添加Red Hat
Network存储库[我使用EPEL ],并通过运行它sudo)。

我有mysqland mysql-server,它解释了为什么MySQL对于每个预先存在的应用程序都能正常运行,但是没有mysql- devel,这对于修复该mysql.h is missing错误和类似的其他构建错误是必需的。

长话短说,mysqldump -u root -ppassword --all-databases > full- dump.sql为了安全起见,用一个简单的固定

sudo yum install mysql-devel
2020-05-17