I used to have RVM installed to manage my Ruby environment and decided to move to rbenv. I did the 'rvm implode' and removed it from Homebrew. Once I installed rbenv though, bundler stopped working whenever it tried to install Nokogiri.
Anyway, I hope this is useful and saves someone else from hours of grief!
$ bundle install
...
Building nokogiri using packaged libraries.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/briley/.rbenv/versions/2.1.3/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/briley/.rbenv/versions/2.1.3/bin/ruby
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
extconf failed, exit code 1
Gem files will remain installed in /Users/briley/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3 for inspection.
Results logged to /Users/briley/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3/gem_make.out
An error occurred while installing nokogiri (1.6.3), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.3'` succeeds before bundling.
Make sure X-Code Command Line Tools are installed:
xcode-select --install
Uninstall libxml2 and libxslt from Homebrew (they're packaged with Nokogiri)
brew uninstall libxslt libxml2
Install libiconv through Homebrew
brew install libiconv
Install the Nokogiri gem manually and specify the paths to libiconv (you may need to change the version #):
gem install nokogiri -- --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
If it continues to fail, check the version of Nokogiri that the error output suggests you install manually (e.g. gem install nokogiri -v '1.6.3'). If the version listed doesn't match the version you have installed (check by running 'gem list'), remove the Gemfile.lock from the project root and then run 'bundle install' again.
I spent hours trying to fix this damn issue only to discover that by simply removing the lock file that it would use the Nokogiri I had installed. Uber frustrating! You should also check the Gemfile and make sure it doesn't specify a specific version of Nokogiri!