首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法安装gem - extconf.rb失败

无法安装gem - extconf.rb失败
EN

Stack Overflow用户
提问于 2018-12-10 14:57:55
回答 1查看 1.2K关注 0票数 1

我将macos升级到Mojave,并重新安装了xcode、xcode CLT、ruby等。然后,当我尝试:

代码语言:javascript
复制
gem install nokogiri

我得到了以下错误(安装其他gem时出现了类似的错误):

代码语言:javascript
复制
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,它包含以下内容:

代码语言:javascript
复制
"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,得到以下错误:

代码语言:javascript
复制
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

..。(为了简短起见,跳过了类似的内容,继续下面的内容)

代码语言:javascript
复制
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上。

希望有人能帮上忙。

EN

回答 1

Stack Overflow用户

发布于 2019-02-08 22:47:50

我不得不运行以下神秘的命令来安装nokogiri。基本上,这需要让我的C编译器在mac osx Mojave上运行,在之前的OS (Yosemite,我认为它是...)上一切都运行得很好。

在升级osx时,这是(有点)显而易见的一步:

代码语言:javascript
复制
xcode-select --install

我也不得不这样做,如果没有谷歌和this post,我永远不会知道该怎么做

代码语言:javascript
复制
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

最后,我不得不同意xcode许可(当nokogiri安装失败时,我发现我不得不通过makefile日志来做这件事...)

代码语言:javascript
复制
sudo xcodebuild -licence

它会提示你最终输入"agree“

最后,在包含nokogiri的新rails项目中继续使用bundle。成功!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53700851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档