当我尝试在Mac OS X 10.6上的nokogiri
上安装ruby-1.8.7-p334 [ x86_64 ]
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.
答案 0 :(得分:3)
在安装nokogiri gem之前,您需要安装库。 以下是使用自制程序
执行此操作的步骤# 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
答案 1 :(得分:0)
我尝试了各种我能找到的解决方案,包括: 。使用brew来安装libxslt / libxml2 / libiconv 。尝试使用各种--with-configurations进行gem安装 遗憾的是,在我卸载MacPort和所有已安装的端口之前,它们都不适合我。
然后只需执行命令gem install nokogiri,gem和rdoc就像轻而易举地安装好了。
我不明白为什么会这么详细,但根据我自己使用MacPort的经验(导致安装了多套ruby / rake / gem)以及比较brew和port的文章,我不会去回到港口。