Installing libxml-ruby for libxml2 with Ruby, on OS X

Just had an exciting package management adventure with Ruby and XML on OS X. I wanted Libxml2 wrapped in a Ruby gem. So, I ran

sudo gem install libxml-ruby

…and watched the software fail to build. Darn OS X not “just being Linux”. After complaining to Christoffer, I was kindly pointed to a MacPort:

sudo port install rb-libxml2

OK, that worked. But I don’t want to use DarwinPorts/MacPorts for my Rubygems, the gems change far too often for that. What I wound up doing was reinstall my gem (sudo gem install libxml-ruby), and then copy the libxml.bundle to its folder:


# cp /usr/local/lib/ruby/gems/1.8/gems/xml/libxml.bundle \
/usr/local/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8/ext/xml/

Also, go into the file

/usr/local/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8/ext/xml/libxml.rb

and change the required file’s name from xml/libxml_so to xml/libxml.bundle.

This was enough to make the thing work!

Moral: The right way to fix this would be to enhance the Makefile of the libxml-ruby gem to teach it about the OS X environment, but: not me, not today. This little tip is what I can do today. Ciao.

[tags]ruby,libxml2[/tags]

2 thoughts on “Installing libxml-ruby for libxml2 with Ruby, on OS X

  1. The right way can most likely be discovered in the patch that DarwinPorts apply to the package. But I guess you already know that. Oh well, good night again.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>