ruby-on-rails - 在 ruby​​-1.8.7-p334 [ x86_64 ] 上使用 rvm 安装 nokogiri gem 时出错

标签 ruby-on-rails makefile rubygems installation nokogiri

当我尝试在 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/

相关文章:

ruby - 任何 ruby​​ 库来检查某些方法采用的参数是什么?

Ruby - 带有 RVM 的全局 "--no-document"

ruby-on-rails - 在 Rails Controller 或普通 ruby​​ 中检查 CSS?

c++ - 如何在windows下制作superlu

c++ - 如何在 makefile 指令中包含 C 和 C++ 文件

c - 不同目录中多个文件的 Makefile

ruby - 使用 bundler ,判断 gem 是否为 "requirable"的最佳方法是什么?

ruby-on-rails - 思考 sphinx : search across multiple models: best practices?

mysql - 在我的 Rails 应用程序中将条件 MySQL 查询语法转换为 Postgres

ruby-on-rails - 使用 FactoryGirl 测试简单的 STI