John Smith
John Smith

Reputation: 311

Libxml2 missing mac os x 10.10

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.

Upvotes: 31

Views: 24250

Answers (8)

Ramses
Ramses

Reputation: 996

This is a bit of a rehash of all the other answers, but this worked for me:

 gem install nokogiri -v '1.6.6.2' -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.16 --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2  --use-system-libraries

Upvotes: 0

conny
conny

Reputation: 10153

(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.

Upvotes: 3

alijandro
alijandro

Reputation: 12167

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.

Upvotes: 0

jakob.j
jakob.j

Reputation: 963

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)

Upvotes: 3

freytag
freytag

Reputation: 4819

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/

Upvotes: 3

lesyk
lesyk

Reputation: 4129

Using ports:

gem install nokogiri -- --use-system-libraries --with-xml=/opt/local/lib/libxml2.a

Upvotes: 1

Taylor Smith
Taylor Smith

Reputation: 151

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/

Upvotes: 15

hlv
hlv

Reputation: 1090

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/

Upvotes: 85

Related Questions