在nokogiri上捆绑安装失败

时间:2013-12-04 15:58:51

标签: ruby bundler nokogiri

我在本网站后面安装了一些主厨依赖:

https://learnchef.opscode.com/starter-use-cases/multi-node-ec2/

我到了bundle install部分,这是我的Gemfile的样子:

source 'https://rubygems.org'

gem 'berkshelf'
gem 'chef'
gem 'knife-ec2'

我尝试运行时遇到此错误     bundle install --path vendor:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
...
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

...
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.

我去了nokogiri网站,我能够按照指示成功安装nokgiri 1.6.0和自制软件.9.5:

nokogiri --version
WARNING: Nokogiri was built against LibXML version 2.9.1, but has dynamically loaded 2.8.0
# Nokogiri (1.6.0)

当我再次尝试运行bundle install时,我收到相同的消息。我被告知捆绑安装程序并不关心在它之外完成的安装。如何绕过这个并安装这些依赖项?

1 个答案:

答案 0 :(得分:6)

经过一番挖掘后,我想通了。这是专门针对OSX Mountain Lion的。

rbenv bundler需要知道使用nokogiri网站提供的这些开关指定的相同路径:

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

这是使用bundler config命令完成的:

bundle config build.nokogiri --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar    /libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

我仍然遇到麻烦,因为配置只占用了该配置设置的第一行。我不得不编辑$ HOME / .bundle / config并取出一些newlnes才能占用所有的开关。我希望这能节省一些时间。