当我尝试在 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 之前,您需要安装库。 以下是使用自制程序执行此操作的步骤
# 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
关于ruby-on-rails - 在 ruby-1.8.7-p334 [ x86_64 ] 上使用 rvm 安装 nokogiri gem 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7209965/