Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /Users/Kartik/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.4.1/ports/x86_64-apple-darwin14.0.0/libxslt/1.1.28)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
i fiddled around with this for quite a while and the following worked for me..
1) install libxml2 with homebrew
brew install libxml2
2) install the gem via
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.4.1 -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/
For any who are still getting "libxml2 version 2.6.21 or later is required!" message, removing --use-system-libraries from hlv's step 2 above, worked for me.
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.4.1 -- --with-xml=/usr/local/Cellar/libxml2/2.9.2/
I finally ended up with this version independent line:
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -n /usr/local/bin -- --with-xml=/usr/local/Cellar/libxml2/
This worked for me (assuming Xcode is installed):
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
Inspired by https://stackoverflow.com/a/28767045/1884907 (credits to lx00st)
(For MacOX 10.12.x) Perhaps you want to brew install libxml2
and also try linking into /usr/local/
first: brew link --force libxml2
, then try that gem install nokogiri -- --use-system-libraries
.
Using ports:
gem install nokogiri -- --use-system-libraries --with-xml=/opt/local/lib/libxml2.a
My solution, using ports:
sudo ARCHFLAGS='-arch x86_64' gem install nokogiri -- --use-system-libraries
By default, it will compile for x86_64 and i386, architecture for i386 should disabled, because the dependencies libraries in port only provide x86_64 version by default.