is rubygems the root of the issue?
Also maybe it could come back as just
def require a
  begin
   old_require a
  rescue LoadError
   require 'rubygems'
   old_require a
  end
end

Cheers!
-roger-