简体   繁体   中英

Failed to install nokogiri and webrat on Mac OS X

I was trying to install webrat on my Mac, but I've got the error, that the iconv.h is missing. Here is the log:

    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

The weird thing is, that the iconv.h is already in the /opt/local/include/ directory.

Can anyone recommend a solution?

thx, tux

Ok, I solved it on my own. After a couple of days on research and trying I figured out, that my installation of g++ and gcc was broken. I've installed an update of g++ through macports, and in the .profile file of my current user there was a value in the PATH var from macports. I removed it, and now it works.

The PATH var should look like this:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

More help on Nokogiri website, using macports or homebrew for Mac OS X install:

http://nokogiri.org/tutorials/installing_nokogiri.html

For iconv related problems, please refer to this issue on github:

https://github.com/tenderlove/nokogiri/issues/381

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM