使用gem在Yosemite上安装Nokogiri

时间:2015-01-22 18:37:28

标签: gem cucumber nokogiri

当我尝试使用以下命令安装Nokogiri时:

gem install nokogiri

我收到以下错误:

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
  ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.

To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions.  If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
*** 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

我在网上看到了很多这些错误,并尝试了解决问题的所有选项,但没有运气。我已经尝试更新Xcode,尝试了gem install nokogiri -- --use-system-libraries,以及libxml2 / libxslt安装,但我仍然无法解决问题。我想知道是否有人有类似的问题,如果是的话,你是怎么解决这个问题的?

2 个答案:

答案 0 :(得分:2)

在执行OS X系统还原和移动某些用户帐户后,我遇到了同样的问题。尽管多次运行xcode-select --install,但错误仍然存​​在。

我可以通过从Apple's download page下载命令行工具的安装包来解决此问题。

答案 1 :(得分:0)

您可以尝试使用RVM。通过为您提供单独的Ruby环境,它可能会消除一些可能导致此问题的可能性,并且在安装Nokogiri时非常聪明。

它还会告诉您是否未正确安装开发人员工具。

相关问题