当前位置: 首页 > 面试题库 >

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

宇文智敏
2023-03-14
问题内容

我正在尝试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

有什么想法吗?


问题答案:

答案与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


 类似资料:
  • 我试图在我的Mac上安装Bundler宝石。使用命令:我得到以下错误: 这显然是一个服务器问题,但我该如何着手解决这个问题呢<代码>gem更新--系统当前是最新的。是否有其他方式获得Bundler?

  • 我得到错误,而试图通过捆绑通过数组列表请帮助 JAVAlang.RuntimeException:无法启动活动组件信息{com.sandyzfeaklab.Breakdown_app/com.sandyzfeaklab.Breakdown_app.Data_input}:java。lang.NullPointerException:尝试调用虚拟方法“java”。木卫一。可序列化的android。操

  • Gem安装bundler给我这个错误。 错误:找不到有效的宝石bundler( 解决办法是什么?

  • Brew安装,显示此错误。请原谅我的无知,我是Mac的新手。 请报告此错误:http://git.io/brew-troubleshootin/System/Library/Frameworks/Ruby。framework/Versions/2.0/usr/lib/ruby/2.0。0/rubygems/core\u ext/kernel\u require。rb:55:inrequire'/u

  • 当我跑的时候

  • 我尝试运行命令,结果出现以下错误。在阅读了一些stackoverflow帖子后,我还运行了。 我仍然得到gem的问题(我猜)。 安装json(1.8.6)时出错,Bundler无法继续。在捆绑之前,请确保成功。这里的问题是没有正确完成安装。