我正在尝试在我的Mac上安装webrat,但是我遇到了错误,即iconv.h缺失了。这是日志:
Building native extensions. This could take a while...
ERROR: Error installing webrat:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include,/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include/libxml2,/usr/include,/usr/include/libxml2... no
iconv is missing. try 'port install iconv' or 'yum install iconv'
*** 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/1.8/usr/bin/ruby
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.1/ext/nokogiri/gem_make.out
奇怪的是,iconv.h已经在/ opt / local / include /目录中。
有人可以推荐一个解决方案吗?
THX, TUX
答案 0 :(得分:0)
好的,我自己解决了。 经过几天的研究和尝试,我发现,我的g ++和gcc的安装被打破了。我已经通过macports安装了g ++的更新,并且在我当前用户的.profile文件中,来自macports的PATH var中有一个值。我删除它,现在它可以工作。
PATH var应如下所示:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
答案 1 :(得分:0)
Nokogiri网站提供更多帮助,使用 macports 或自制安装Mac OS X:
http://nokogiri.org/tutorials/installing_nokogiri.html
对于 iconv 相关问题,请参阅github上的这个问题: