Problem:
The following commands fail on OSX:
gem install nokogiri
gem install nokogiri -- --use-system-libraries
gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-dir=/usr/local/opt/libxml2
Version:
libxml2: 2.9.4 (installed via homebrew 0.9.9)
libxslt: 1.1.28
nokogiri: 1.6.8
If you tried the last command mentioned above, and the following error message, then this guide might solve your problem:
ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
The problem I noticed is that the xmlversion.h
header
file won't be discovered by extconf.rb
script because the inferred
path of the include
directory by nokogiri is
/usr/local/opt/libxml2/include
. But in the libxml2 2.9.4
version, the path to the header file is
/usr/local/opt/libxml2/include/libxml2/xmlversion.h
.
Specifying the include
and lib
paths explicitly solves the problem:
gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib
I'm not sure if this even a bug, either in functionality or documentation.
Thanks, this worked for me