自OSX Mojave 10.14.2起无法在Rails应用中安装Nokogiri

时间:2019-01-09 17:27:46

标签: ruby-on-rails nokogiri macos-mojave

由于最近的更新(10.14.2)Nokogiri gem无法安装在我的应用中。

运行bundle install时出现此错误:

./siteconf20190109-70456-1diyett.rb extconf.rb --use-system-libraries
checking if the C compiler accepts -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE
-fstack-protector-strong -O2 -pipe... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future...
no
Building nokogiri using system libraries.
Using pkg-config gem version 1.3.2
checking for libxml-2.0... yes
checking for libxslt... yes
checking for libexslt... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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.

我已经检查了Nokogiri's installation guide中的Mojave,但即使使用了此补丁,它也无法正常工作:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

设置:

操作系统: OSX Mojave 10.14.2

Ruby版本: 红宝石2.4.4p296(2018-03-28修订版63013)[x86_64-darwin17]

您有解决此问题的想法吗?

预先感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

该日志消息表明libxml2丢失。 因此,尝试运行此代码:

   brew install libxml2

如果已安装自制软件。 选中此link以获得更多信息。