错误通过Bundler安装mysql2 gem [英] Errors Installing mysql2 gem via the Bundler

查看:92
本文介绍了错误通过Bundler安装mysql2 gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  **执行命令
/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb :483:在'在build_extensions中的块中救援':
错误:无法构建gem原生扩展。 (Gem :: Installer :: ExtensionBuildError)

/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --with-mysql-config = / usr / bin / mysql_config
检查rb_thread_blocking_region()...是
检查mysql.h ...否
检查mysql / mysql.h ...否

-----
mysql.h缺失。请检查你的mysql安装并重试。
-----

*** extconf.rb失败***
由于某些原因无法创建Makefile,可能缺少必要的
库和/或标题。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--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文件将继续安装以供检查。

我通过Googling发现的大部分内容都建议通过 - with-mysql- config 参数来修复它。所以,根据:

  $ which mysql_config 
/ usr / bin / mysql_config

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

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

然而,仍然没有运气 - 与上面相同的崩溃。



由于错误 mysql.h丢失,我检查过它,据说它在周围,只是Bundler找不到。

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

有什么想法? 解决方案

答案类似于Wrikken发布的答案 - 为了将来的读者。


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

执行安装sudo yum列表将打印出你机器上所有已安装的软件包(注意:RHEL上的 yum )需要添加一个红帽网络存储库[我使用 EPEL ],并通过 sudo 来运行。)



我有 mysql mysql-server ,这解释了为什么MySQL对每个预先存在应用程序,但没有 mysql-devel ,这是修复 mysql.h缺失错误和类似的其他构建所必需的错误。

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

 修复了sudo yum install mysql- devel 


I am trying to install the mysql2 gem via the Bundler, but it keeps dying with the following error:

** 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.

Most things I found via Googling recommended passing the --with-mysql-config parameter to fix it. So, based on:

$ which mysql_config
/usr/bin/mysql_config

I added the following to the Bundler's config:

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

However, still no luck -- same crash as above.

Since it's dying with the error mysql.h is missing, I checked for that, and it's allegedly around, just can't be found by the Bundler.

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

Any thoughts?

解决方案

Answer was similar to the one Wrikken posted -- here's what I did to fix it for the sake of future readers.

(This is for RHEL 5.5 -- similar but different commands apply for Ubuntu/Debian/etc.)

Doing sudo yum list installed will print out all installed packages on your machine (note: yum on RHEL requires you add a Red Hat Network repository [I use EPEL], and run it via sudo).

I had mysql and mysql-server, which explained why MySQL worked fine for every pre-existing app, but no mysql-devel, which is necessary to fix that mysql.h is missing error and similar other build errors.

Long story short, after a mysqldump -u root -ppassword --all-databases > full-dump.sql for safety, it was fixed with a simple

sudo yum install mysql-devel

这篇关于错误通过Bundler安装mysql2 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆