14 February 2012

Nokogiri Segmentation Fault on Mac Lion

I have a web project running on ruby-1.8.7-p352 with Nokogiri 1.5.0. It works well until I incidentally did a system update. When I started rails server, tried to access my website, the server would throw an exception and abort. The error message I got was like the following:
nokogiri-1.5.0/lib/nokogiri/xml/node.rb:930: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]
The Nokogiri information was like the following:
# Nokogiri (1.5.0)
    --- 
    warnings: []
    
    ruby: 
      engine: mri
      version: 1.8.7
      description: ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]
      platform: i686-darwin11.2.0
    libxml: 
      loaded: 2.7.3
      binding: extension
      compiled: 2.7.3
    nokogiri: 1.5.0

I've done some research online, and all the results suggest that this problem is caused by the outdated libxml, and some of them fixed the problem by re-installing Nokogiri on libxml 2.7.8. And here is the link that I found really useful, which helped to fix my problem too.

So, the following is what I'd done to fix it:
#gem uninstall nokogiri
#sudo port selfupdate
#sudo port install libxml
=== Open a new terminal window ===
#gem install nokogiri
Now check the Nokogiri information again, and you'll see the libxml has been upgraded to 2.7.8:
# Nokogiri (1.5.0)
    --- 
    warnings: []
    
    ruby: 
      engine: mri
      version: 1.8.7
      description: ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]
      platform: i686-darwin11.2.0
    libxml: 
      loaded: 2.7.8
      binding: extension
      compiled: 2.7.8
    nokogiri: 1.5.0
Start the rails server, and everything is back to normal.

Hope this helps.


Cheers,
Felix

No comments:

Post a Comment