Error installing Nokogiri on bundle install but already installed

I had the same issues, but I solved it by installing nokogiri this way:

gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2

...then all was right with the world. I'll try:

bundle config build.nokogiri --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2

...on my next rails app.

OS X 10.9.5

libxml2 2.9.2

Ruby 2.2.2

Rails 4.2.1

Nokogiri 1.6.6.2


brew install libxml2
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
bundle install

it's work for me

(source here)


Try running bundle config build.nokogiri --use-system-libraries as noted in the bundler output. Then re-run bundle.