[Rubygems-developers] exception during require 'somegem'

Ben Walton bwalton at artsci.utoronto.ca
Wed Jul 16 12:47:32 EDT 2008

Hi List,

I'm in the process of setting up RoR on an old solaris 8 box and have
been building/installing ruby, etc by hand to get things going.  This
has led me to a problem with rubygems when gems are installed using an
overly strict umask.

If a user doesn't have rights to read the gem specification file, the
script 'requiring' the gem in question was bombing out with an unhandled 
exception in site_ruby/1.8/rubygems/source_index.rb (line 96).  Looking
at the code, it was due to spec_code being uninitialized (since the
exception was generated during the call to File.read(file_name) above.

The exception handler for this dumps the exception string concatenated
with the value of spec_code in a call to alert_warning.  This string
concatenation is the culprit that generates another exception when
spec_code is nil.

This isn't a proper patch, but I hope you'll use it (as at least a
reference) to correct the behaviour of the gem library in this case.

# diff source_index.rb*
<         alert_warning(e.inspect.to_s + "\n" + spec_code.to_s)
>         alert_warning(e.inspect.to_s + "\n" + spec_code)

My testing with this 'patch' applied shows that it does allow the
alert_warning method to proceed (whether it should or not is something
I'm not familiar enough with the inner workings of gems to answer)
causing things to die more normally later on during the require process.

Hope this helps.  Keep up the good work guys and girls!

Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu
Contact me to arrange for a CAcert assurance meeting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/rubygems-developers/attachments/20080716/bb89abbe/attachment.bin>

More information about the Rubygems-developers mailing list