无法安装宝石 - extconf.rb失败

问题描述 投票:0回答:1

我升级MacOS的莫哈韦并重新安装的Xcode,Xcode的CLT,红宝石,等等。然后当我尝试:

gem install nokogiri

我得到了以下错误(安装其他宝石给出了类似的错误):

ERROR: Failed to build gem native extension.

current directory: /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20181209-20884-etfc5r.rb extconf.rb
checking if the C compiler accepts ... *** 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.

我查了mkmf.log,它包含以下内容:

"clang -o conftest -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/x86_64-darwin18 -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/backward -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/usr/local/Cellar/ruby/2.5.3_1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib     -lruby.2.5.3  -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:

文本继续像这一段时间。我也cd到引入nokogiri文件夹,并直接运行extconf.rb,并得到了以下错误:

checking if the C compiler accepts ... *** 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

...(跳过简洁类似的内容及以下续)

usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:456:in 'try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

我试图安装的Xcode。我还安装了头,并承认许可证。我起初以为它与GCC做,但MKMF文件表明,该问题是与Clang

希望有人能提供帮助。

ruby macos-mojave
1个回答
0
投票

我只好跑得到引入nokogiri安装下面的密码命令。基本上,这需要让我的C编译器在Mac OSX上莫哈韦工作,拥有一切在以前的操作系统工作正常后(约塞米蒂我认为这是...)

这是在升级OSX当(有点)明显步骤:

xcode-select --install

我也不得不这样做,这是我永远不会已经知道如何在不谷歌和this post

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

最后,我不得不同意Xcode的许可证(发现我已经通过Makefile日志要做到这一点,当失败引入nokogiri的安装...)

sudo xcodebuild -licence

它会提示你输入最终“同意”

最后,继续与bundle按预期工作的一个新的Rails项目,包括引入nokogiri。成功!

© www.soinside.com 2019 - 2024. All rights reserved.