Nokogiri v 1.8.1 issue when running Bundle Install

On high sierra (and mojave), this worked for me

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

bundle update

bundle install

I'm just posting the solution I found (I had the same problem on MacOS). With this, the gem will be installed using the system libraries, which should solve the probleme you encountered.

  1. If using gem:
gem install nokogiri -- --use-system-libraries
 [--with-xml2-config=/path/to/xml2-config]
 [--with-xslt-config=/path/to/xslt-config]
  1. If using bundle:
bundle config build.nokogiri --use-system-libraries
bundle install

Nokogiri fails to build normaly because you don't have dev libraries like libxml2. Look at the log file to see what happens or try to install libxml2 directly with brew install libxml2

See throubleshoting guide provided by Nokogiry at http://www.nokogiri.org/tutorials/installing_nokogiri.html


(for UBUNTU) First try to do this

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzmadev

then try to install.