1

I'm installing some chef dependencies following this website:

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

I got to the bundle install part, here's what my Gemfile looks like:

source 'https://rubygems.org'

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

I get this error when I try to run 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.

I went to the nokogiri site and I was able to follow the directions and successfully install nokgiri 1.6.0 with homebrew .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)

I get the same message when I then try running the bundle install again. I'm told that the bundle installer doesn't care about installs done outside of it. How to I get around this and install these dependencies?

numb3rs1x
  • 4,673
  • 5
  • 31
  • 44
  • Same issue here : http://stackoverflow.com/questions/5528839/installing-nokogiri-fails-libiconv-missing – JoJoS Dec 04 '13 at 16:05
  • Not quite. I was able to successfully install it using gem. There's a dependency within a bundle install thought that doesn't see that I installed nokogiri using gem. – numb3rs1x Dec 04 '13 at 17:16

1 Answers1

6

After a little digging, I figured it out. This is specifically for OSX Mountain Lion.

The rbenv bundler needs to know the same paths specified using these switches given by the nokogiri site:

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

This is done using the bundler config command:

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

I still ran into troulbe because the config was only picking up the first line of that config setting. I had to edit $HOME/.bundle/config and take out some newlnes before it would take all of the switches. I hope this will save someone else some time.

numb3rs1x
  • 4,673
  • 5
  • 31
  • 44