【发布时间】:2011-07-28 13:58:07
【问题描述】:
我一直在尝试在 Mac OS 10.9.3 上安装 Nokogiri,无论我尝试什么,安装最终都会失败并显示以下错误消息:
$ sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib'
This could take a while...
Building nokogiri using packaged libraries.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out
在网上找到很多帮助后,包括使用 brew 构建和安装 libxml2 和 libxslt 以及从源代码构建 libiconv(如“Installing Nokogiri”中所述),错误仍然存在。
在尝试运行 Nokogiri 的安装时,似乎发现 libxml2 和 libxslt 正常,但 libiconv 不正常。
任何对这些事情有更深入了解的人都知道如何安装 Nokogiri 吗?
【问题讨论】:
-
您没有显示您尝试使用的确切命令,因此我们将在黑暗中拍摄试图回答。我总是使用
gem install nokogiri,但后来我使用 RVM 来管理我的 Mac OS Ruby 安装。 libxml 和 libxslt 与 iconv 无关,所以我建议您在他们的支持论坛Nokogiri-talk 上提问。我不记得在安装 Nokogiri 时遇到任何 iconv 问题,而且我在一堆机器上都有它。 -
我在 github 上开了一张票:github.com/tenderlove/nokogiri/issues/442 其中包含更多信息。
-
这是解决 OSX El Capitan 上相同问题的链接,estebantorr.es/blog/2015/10/02/Nokogiri-in-El-Capitan
-
“
sudo gem install nokogiri”。不要使用sudo安装gem 或修改默认的Ruby。而是使用 rbenv 或 RVM 来管理单独的 Ruby。这在 Stack Overflow 上已多次提及。 -
在安装 nokogiri 之前您是否尝试过uninstalling xz?
标签: ruby macos nokogiri libxml2 libiconv