Ruby 1.9.2 becomes corrupted on Centos

We recently completed a fresh compile of Ruby 1.9.2 from sources on a Centos machine.   After a few days, the Ruby interpreter itself seemed to get corrupted.  The problem manifested itself as the interpreter failing to load rubygems.  See the Output Trace at the end of this article for what we saw.

Two articles on the web suggested that the Linux prelink optimizer was actually corrupting the Ruby binary.  The solution is to tell the system to BAN prelinking on the Ruby binary.  After adding the “-b /usr/bin/ruby” line to the /etc/prelink.conf file as suggested, the problem seems to have gone away.

I’m reposting the links to these articles to help others in a similar situation find this information.  These saved us a lot of time diagnosing a very mysterious problem.

The Referenced Articles

http://www.improvingwetware.com/2011/04/07/strange-error-from-rubygems-due-to-linux-prelink-hellip

http://www.ruby-forum.com/topic/205897

The Output Trace

#irb
<internal:lib/rubygems/custom_require>:29:in `require': closed stream(IOError)  
from <internal:lib/rubygems/custom_require>:29:in `require'  
from /usr/lib/ruby/1.9.1/irb.rb:13:in `<top (required)>'  
from <internal:lib/rubygems/custom_require>:29:in `require'  
from <internal:lib/rubygems/custom_require>:29:in `require'  from /usr/bin/irb:9:in `<main>'

Leave a Reply

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