当我尝试在Mac OS X 10.6的ruby-1.8.7-p334 [ x86_64 ]
上安装nokogiri
gem时,我得到以下错误:
sudo gem install nokogiri
/Users/patelc75/.rvm/rubies/ruby-1.8.7-p334/bin/gem:4: warning: Insecure world writable dir /Users in PATH, mode 040777
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/patelc75/.rvm/rubies/ruby-1.8.7-p334/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_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.
在安装nokogiri gem之前,您需要安装库。以下是使用homebrew
完成此操作的步骤# the rest of this snippet assumes installation of libxml 2.7.7. YMMV.
brew install libxml2
brew link libxml2
# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26
--with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
make
sudo make install
gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
与macports sudo port install libxml2 libxslt
sudo gem install nokogiri
更多信息在这里http://nokogiri.org/tutorials/installing_nokogiri.html
我尝试了我能找到的各种解决方案,包括:。使用brew安装libxslt/libxml2/libiconv。尝试使用各种——with-configuration进行gem安装遗憾的是,它们都不适合我,直到我卸载了MacPort和所有已安装的端口。
然后简单地执行命令gem install nokogiri, gem和rdoc就像微风一样安装好了。
我不明白为什么,但根据我自己使用MacPort的经验(导致安装了多套ruby/rake/gem)和比较brew和port的文章,我不会回到port。