On your MAC OSx, if you have upgraded to latest Ruby 2.1.5 (or even 2.1.2) then there are high chances that you will face issues installing "nokogiri" gem. You might face errors like

ERROR: Failed to build gem native extension.

Following are the steps to resolve these issues on your Mac OSx

  1. brew install libxml2

  2. Read complete error dump on console while you do "bundle" or "bundle install". You would notice that there are useful tips to fix this on your PC, example

for Building Nokogiri with a packaged version of libxml2-2.9.2, execute this command on your console

bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2"

(Basically issue on my PC was due to "libxml2")

  1. Last option in step 2 above helped me.i.e. manually configuring the include path "with-xml2-include". Finally try installing nokigiri gem again and if still shows the errors then follow these steps

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


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