Nokogiri 'Failed to build gem native extension' when I run bundle install

On Mavericks this workaround worked for me:

gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2

See: https://github.com/sparklemotion/nokogiri/issues/1099#issuecomment-43023208


On Amazon Linux, I had to install these two devel libraries, and then specify the include path for libxml2

$ yum install libxml2-devel libxslt-devel
$ gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2/

Previous advises didn't help me, here is the solution for OS 10.9:

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