当我尝试使用以下命令安装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安装,但我仍然无法纠正问题。我想知道是否有人遇到过类似的问题,如果是这样,您是如何解决这个问题的?
在执行OS X系统还原并移动某些用户帐户后,我遇到了同样的问题。尽管多次运行xcode-select --install
,但错误仍然存在。
我能够通过从Apple的下载页面下载命令行工具的安装包来解决此问题。
您可以尝试使用 RVM。通过为您提供单独的Ruby环境,它可能会消除一些可能导致此问题的可能性,并且在安装Nokogiri方面非常聪明。
它还会告诉您是否尚未正确安装开发人员工具。