如何将mysql2捆绑到Rails项目上现有的ruby

时间:2019-06-06 17:00:42

标签: mysql ruby-on-rails macos

Mac OS Mojave 10.14.5

我在Rails的ruby中安装mysql gem时遇到问题。我运行捆绑安装后,将显示以下消息:

Fetching mysql2 0.4.4
Installing mysql2 0.4.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:

/Users/urijkunicyn/.rvm/gems/ruby-2.3.1/gems/mysql2-0.4.4/ext/mysql2
/Users/urijkunicyn/.rvm/rubies/ruby-2.3.1/bin/ruby -I
/Users/urijkunicyn/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0 -r
./siteconf20190606-13348-77enf9.rb extconf.rb
checking for ruby/thread.h... *** 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
--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=/Users/urijkunicyn/.rvm/rubies/ruby-  2.3.1/bin/$(RUBY_BASE_NAME)
/Users/urijkunicyn/.rvm/rubies/ruby-    2.3.1/lib/ruby/2.3.0/mkmf.rb:456:in
`try_do': The compiler failed to generate an executable file.     (RuntimeError)
You have to install development tools first.
from /Users/urijkunicyn/.rvm/rubies/ruby-    2.3.1/lib/ruby/2.3.0/mkmf.rb:587:in

try_cpp' from /Users/urijkunicyn/.rvm/rubies/ruby- 2.3.1/lib/ruby/2.3.0/mkmf.rb:1091:in 在have_header中被屏蔽'          来自/Users/urijkunicyn/.rvm/rubies/ruby- 2.3.1 / lib / ruby​​ / 2.3.0 / mkmf.rb:942:in    block in checking_for' from /Users/urijkunicyn/.rvm/rubies/ruby- 2.3.1/lib/ruby/2.3.0/mkmf.rb:350:in 阻止(2个级别)推迟”    来自/Users/urijkunicyn/.rvm/rubies/ruby- 2.3.1 / lib / ruby​​ / 2.3.0 / mkmf.rb:320:in    open' from /Users/urijkunicyn/.rvm/rubies/ruby- 2.3.1/lib/ruby/2.3.0/mkmf.rb:350:in 阻止推迟”     来自/Users/urijkunicyn/.rvm/rubies/ruby- 2.3.1 / lib / ruby​​ / 2.3.0 / mkmf.rb:320:in    open' from /Users/urijkunicyn/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:346:in 推迟” 来自/Users/urijkunicyn/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:941:in checking_for' from /Users/urijkunicyn/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:1090:in have_header'     来自extconf.rb:16:in''

要查看此扩展为何无法编译,请检查mkmf.log,该文件可以 在这里找到:

/Users/urijkunicyn/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-16/2.3.0/mysql2-0.4.4/mkmf.log

extconf失败,退出代码1

宝石文件将继续安装在 /Users/urijkunicyn/.rvm/gems/ruby-2.3.1/gems/mysql2-0.4.4进行检查。 结果记录到 /Users/urijkunicyn/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-16/2.3.0/mysql2-0.4.4/gem_make.out

在安装mysql2(0.4.4)时发生错误,并且Bundler无法 继续。 确保gem install mysql2 -v '0.4.4' --source 'https://rubygems.org/' 捆绑前成功。

0 个答案:

没有答案