Sunday, February 24, 2008

libxml ruby gem installation issues

Though as much as I hate dealing with the verbose xml format, xml has become so ubiquitous that one can no longer ignore it. Hence I decided to play around a little with xml and ruby on my ubuntu 7.10(Gutsy Gibbon). The most obvious and easier way to deal with xml on ruby is using rexml. However, if performance is your need then one will have to use the ruby bindings to the libxml library (which I guess explains the performance).

However as I installed gem and ran a sample test program, the ruby interpreter shouted back

/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- libxml_so (LoadError)

After searching on the net, got to know that the library 'libxml_so.so' is indeed generated during gem installation but not copied on the target folder. Hence follow the following procedure to avoid the issues
  1. gem install -r libxml-ruby
  2. Write some sample program (just include ' require xml/libxml', no need for any actual api calls). If this fails pointing to libxml_so.so, then follow the next steps. Else you are good to go
  3. goto /var/lib/gems/1.8/gems/libxml-ruby-0.x.x
  4. run 'ruby ext/libxml/extconf.rb'. This generates the makefile
  5. run 'make' and then 'make install'
  6. go back to your test program and run it. Hopefully everything should be fine.

4 comments:

Laurent Farcy said...

Thanks so much for this post. It basically saved my day while I was in a rush to upgrade my production server.

stevie said...

ditto, huge help. Pretty annoying that this isn't fixed in the libxml-ruby source. I'm installing on CentOS and hit the exact same problem.

Mene said...

Awesome...so awesome... thanks a lot... ive been searching it from 2 days..u make my day

Arshad said...

Hi! I did it exactly as instructed and succeded in installing libxml but it didn't fix my problem. Pls post any alternative soln if any. Thanks