# RubyGems Patch

**URL:** <https://www.ruby-forum.com/t/rubygems-patch/149459>\
**Category:** IronRuby\
**Created:** [September 25, 2008, 1:13am UTC](https://www.ruby-forum.com/t/rubygems-patch/149459 "2008-09-25T01:13:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TurpinS\_Jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d9b06d/32.png) [@TurpinS\_Jay](https://www.ruby-forum.com/u/TurpinS_Jay)\
**Post date:** [September 25, 2008, 1:13am UTC](https://www.ruby-forum.com/t/rubygems-patch/149459/1 "2008-09-25T01:13:59Z")

</div>

I finally tracked down a bug that was causing an error when trying to  
use rubygems and rake. When a .gemspec was being read and evaluated to  
create a Gem::Specification instance, it was not creating a Gem::Version  
object properly. Turns out that the Version.create() method was checking  
to see if the parameter responds\_to? :version. Somewhere along the line,  
the String class added a version method - which caused the error.

Regards,  
Jay Turpin  
“Always do right. This will gratify some people and astonish the rest.”

- Mark Twain  
From: Turpin, Jay  
Sent: Tuesday, September 23, 2008 10:36 AM  
To: ‘removed\_email\_address@domain.invalid’  
Subject: RE: [Ironruby-core] question on RubyGems

Tomas - The problem seems to be coming from rubygems/custom\_required.rb.  
It redefines Kernel.required() and is not re-throwing the error  
properly:

This works:

module Kernel  
alias gem\_original\_require require # :nodoc:

def require(path) # :nodoc:  
gem\_original\_require path  
end  
end # module Kernel

but this doesn’t:

module Kernel  
alias gem\_original\_require require # :nodoc:

def require(path) # :nodoc:  
gem\_original\_require path  
rescue LoadError =\> load\_error  
raise load\_error  
end  
end # module Kernel

Regards,  
Jay Turpin  
“It is always the best policy to tell the truth, unless, of course, you  
are an exceptionally good liar.” - Jerome K. Jerome  
From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tomas M.  
Sent: Tuesday, September 23, 2008 10:12 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] question on RubyGems

I see. Well it seems more broken than I thought it is 🙂

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Turpin, Jay  
Sent: Tuesday, September 23, 2008 9:37 AM  
To: ‘removed\_email\_address@domain.invalid’  
Subject: Re: [Ironruby-core] question on RubyGems

Tomas - Thanks for the advice. However, it is still not working as  
expected. When I run this ruby script:

require ‘rubygems’  
require ‘rake’

puts $LOAD\_PATH

It give me this output:

C:\temp\>ir -D t.rb  
C:/Projects/IronRuby/lib/ruby/site\_ruby/1.8\rubygems/custom\_require.rb:31:in  
`require': Bogus Error (RuntimeError) from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in `Call3’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in  
`UpdateAndExecute' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in `Update3’  
from t.rb:3  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in  
`Call3' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in `UpdateAndExecute’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in  
`Update3’  
from t.rb:3

But the error is actually coming from deep inside the rubygems library

Thanks!

Regards,  
Jay Turpin  
“In the end, everything is a gag.” - Charlie Chaplin  
From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tomas M.  
Sent: Tuesday, September 23, 2008 9:30 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] question on RubyGems

-D is actually what you need:

C:\Temp\>rbd x.rb  
C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSite.cs:275:in  
`UpdateAndExecute' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs:38:in `Update2’  
x.rb:7:in `bar' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\MatchCaller.Generated.cs:30:in `Call2’  
C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSite.cs:275:in  
`UpdateAndExecute' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs:38:in `Update2’  
x.rb:3:in `foo' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\MatchCaller.Generated.cs:30:in `Call2’  
C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSite.cs:275:in  
`UpdateAndExecute' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs:38:in `Update2’  
x.rb:10

As I said, some internal frames are included as well, which is a bug  
that I’m going to fix soon.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Turpin, Jay  
Sent: Tuesday, September 23, 2008 9:15 AM  
To: ‘removed\_email\_address@domain.invalid’  
Subject: Re: [Ironruby-core] question on RubyGems

Michael - Thanks for the quick response, but that’s not quite what I  
meant. When I run Ruby and get an error, I get the complete stack trace  
of the Ruby code:

C:\temp\>ruby t.rb  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/version.rb:283:in `satisfy?': Bogus Error (RuntimeError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:273:in `satisfied\_by?’  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/source\_index.rb:86:in `all?' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:273:in `each’  
from c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/version.rb:273:in  
`all?' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:273:in `satisfied\_by?’  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/source\_index.rb:187:in `search' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:185:in `each’  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/source\_index.rb:185:in `search' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:165:in `find\_name’  
from c:/ruby/lib/ruby/site\_ruby/1.8/rubygems.rb:187:in  
`activate' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require’  
from t.rb:2

However, when I run IronRuby and get an error, I only get one line of  
ruby code and the rest is the C# stack trace:

C:\temp\>ir t.rb  
custom\_require.rb:26:in `require': Bogus Error (RuntimeError) from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in `Call3’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in  
`UpdateAndExecute' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in `Update3’  
from :0  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in  
`Call3' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in `UpdateAndExecute’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in  
`Update3’  
from :0

The error really happens deep inside the Ruby code. Any ideas?

Thanks

Regards,  
Jay Turpin  
“Over 48.7% of all statistics are useless.” - Anonymous

---

<div class="post-metadata">

**Author:** ![TurpinS\_Jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d9b06d/32.png) [@TurpinS\_Jay](https://www.ruby-forum.com/u/TurpinS_Jay)\
**Post date:** [September 25, 2008, 1:27am UTC](https://www.ruby-forum.com/t/rubygems-patch/149459/2 "2008-09-25T01:27:27Z")

</div>

Yes, I found the same thing yesterday :). The patch I submitted for  
review a few hours ago contains a fix for this.

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Turpin, Jay  
Sent: Wednesday, September 24, 2008 4:13 PM  
To: ‘removed\_email\_address@domain.invalid’  
Subject: [Ironruby-core] RubyGems Patch

I finally tracked down a bug that was causing an error when trying to  
use rubygems and rake. When a .gemspec was being read and evaluated to  
create a Gem::Specification instance, it was not creating a Gem::Version  
object properly. Turns out that the Version.create() method was checking  
to see if the parameter responds\_to? :version. Somewhere along the line,  
the String class added a version method - which caused the error.

Regards,  
Jay Turpin  
“Always do right. This will gratify some people and astonish the rest.”

- Mark Twain  
From: Turpin, Jay  
Sent: Tuesday, September 23, 2008 10:36 AM  
To: ‘removed\_email\_address@domain.invalid’  
Subject: RE: [Ironruby-core] question on RubyGems

Tomas - The problem seems to be coming from rubygems/custom\_required.rb.  
It redefines Kernel.required() and is not re-throwing the error  
properly:

This works:

module Kernel  
alias gem\_original\_require require # :nodoc:

def require(path) # :nodoc:  
gem\_original\_require path  
end  
end # module Kernel

but this doesn’t:

module Kernel  
alias gem\_original\_require require # :nodoc:

def require(path) # :nodoc:  
gem\_original\_require path  
rescue LoadError =\> load\_error  
raise load\_error  
end  
end # module Kernel

Regards,  
Jay Turpin  
“It is always the best policy to tell the truth, unless, of course, you  
are an exceptionally good liar.” - Jerome K. Jerome  
From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tomas M.  
Sent: Tuesday, September 23, 2008 10:12 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] question on RubyGems

I see. Well it seems more broken than I thought it is 🙂

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Turpin, Jay  
Sent: Tuesday, September 23, 2008 9:37 AM  
To: ‘removed\_email\_address@domain.invalid’  
Subject: Re: [Ironruby-core] question on RubyGems

Tomas - Thanks for the advice. However, it is still not working as  
expected. When I run this ruby script:

require ‘rubygems’  
require ‘rake’

puts $LOAD\_PATH

It give me this output:

C:\temp\>ir -D t.rb  
C:/Projects/IronRuby/lib/ruby/site\_ruby/1.8\rubygems/custom\_require.rb:31:in  
`require': Bogus Error (RuntimeError) from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in `Call3’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in  
`UpdateAndExecute' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in `Update3’  
from t.rb:3  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in  
`Call3' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in `UpdateAndExecute’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in  
`Update3’  
from t.rb:3

But the error is actually coming from deep inside the rubygems library

Thanks!

Regards,  
Jay Turpin  
“In the end, everything is a gag.” - Charlie Chaplin  
From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tomas M.  
Sent: Tuesday, September 23, 2008 9:30 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] question on RubyGems

-D is actually what you need:

C:\Temp\>rbd x.rb  
C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSite.cs:275:in  
`UpdateAndExecute' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs:38:in `Update2’  
x.rb:7:in `bar' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\MatchCaller.Generated.cs:30:in `Call2’  
C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSite.cs:275:in  
`UpdateAndExecute' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs:38:in `Update2’  
x.rb:3:in `foo' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\MatchCaller.Generated.cs:30:in `Call2’  
C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSite.cs:275:in  
`UpdateAndExecute' C:\M1\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs:38:in `Update2’  
x.rb:10

As I said, some internal frames are included as well, which is a bug  
that I’m going to fix soon.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Turpin, Jay  
Sent: Tuesday, September 23, 2008 9:15 AM  
To: ‘removed\_email\_address@domain.invalid’  
Subject: Re: [Ironruby-core] question on RubyGems

Michael - Thanks for the quick response, but that’s not quite what I  
meant. When I run Ruby and get an error, I get the complete stack trace  
of the Ruby code:

C:\temp\>ruby t.rb  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/version.rb:283:in `satisfy?': Bogus Error (RuntimeError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:273:in `satisfied\_by?’  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/source\_index.rb:86:in `all?' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:273:in `each’  
from c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/version.rb:273:in  
`all?' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:273:in `satisfied\_by?’  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/source\_index.rb:187:in `search' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:185:in `each’  
from  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/source\_index.rb:185:in `search' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:165:in `find\_name’  
from c:/ruby/lib/ruby/site\_ruby/1.8/rubygems.rb:187:in  
`activate' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require’  
from t.rb:2

However, when I run IronRuby and get an error, I only get one line of  
ruby code and the rest is the C# stack trace:

C:\temp\>ir t.rb  
custom\_require.rb:26:in `require': Bogus Error (RuntimeError) from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in `Call3’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in  
`UpdateAndExecute' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in `Update3’  
from :0  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in  
`Call3' from C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in `UpdateAndExecute’  
from  
C:\Projects\IronRuby\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in  
`Update3’  
from :0

The error really happens deep inside the Ruby code. Any ideas?

Thanks

Regards,  
Jay Turpin  
“Over 48.7% of all statistics are useless.” - Anonymous
