Question

I've been struggling with this error installing libxml-ruby while setting up my active merchant git. I've Googled all the components of the error many times, but I'm just not really sure what I'm looking at. There's a bunch of "no's" - anybody know how to interpret what I may be missing?

Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
ERROR: Failed to build gem native extension.

/Users/tommynicholas/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for libxml/xmlversion.h... no
checking for libxml/xmlversion.h in     /opt/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... no
*** 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.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/tommynicholas/.rvm/rubies/ruby-2.1.1/bin/ruby
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-socketlib
--without-socketlib
--with-nsllib
--without-nsllib
--with-mlib
--without-mlib
--with-zlib
--without-zlib
--with-iconvlib
--without-iconvlib
--with-xml2-config
--without-xml2-config
--with-xml2lib
--without-xml2lib
extconf failure: need libxml2.

Install the library or try one of the following options to extconf.rb:

  --with-xml2-config=/path/to/xml2-config
  --with-xml2-dir=/path/to/libxml2
  --with-xml2-lib=/path/to/libxml2/lib
  --with-xml2-include=/path/to/libxml2/include


extconf failed, exit code 1

Gem files will remain installed in /Users/tommynicholas/.rvm/rubies/ruby-    2.1.1/lib/ruby/gems/2.1.0/gems/libxml-ruby-2.7.0 for inspection.
Results logged to /Users/tommynicholas/.rvm/rubies/ruby-    2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0/libxml-ruby-2.7.0/gem_make.out
Was it helpful?

Solution

checking for libxml/xmlversion.h in /opt/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... no

Tells me you might be missing libxml2

Try to install it:

sudo apt-get install libxml2-dev

Well, as @TommyNicholas requested, I will try to explain why I zoomed in on libxml2 out of all others - it was a bit of a gut feeling, but I had some clues:

  1. It was the last line before the install declares failure, so that line has a lot of potential of being a critical error (the installation continues after the other failures...) it may not be the only one, but it deserves attention.
  2. The error message shows that it searched libxml2 under /opt/include/, /usr/local/include/ and usr/include/ - and didn't find it, so it stands to reason that it is not installed.
  3. A similar error is known to happen when installing Nokogiri, so it doesn't hurt to try the same solution.
  4. Anyway, if all else fail - RTFM - although my guess worked, the next step is to read the error message, which hints that there may be a more complete report in the logs - mkmg.log:

Check the mkmf.log file for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top