Gavin Kistner
8/15/2006 5:38:00 PM
Hrm, mine doesn't work quite like yours, but I got it to work.
Crazy-cased gem. Thanks.
To hijack my own thread: Why doesn't require work the same as
require_gem? Both find the Usage.rb file and load it, but using require
causes it not to properly run the "require_gem "SimpleTrace", "<=
0.1.0" command inside Usage.rb, resulting in the error shown in the
first block below:
===
# Thought it should work, given my RUBYOPT setting; but it doesn't.
# Case doesn't matter here, on Windows.
===
require 'Usage' # or require 'usage'; same effect
p Usage
#=> Usage
p Usage.new( "foo" )
C:/ruby/lib/ruby/gems/1.8/gems/usage-0.0.4/lib/Usage.rb:605:in
`initialize': undefined method `debug' for nil:NilClass (NoMethodError)
from C:/ruby/lib/ruby/gems/1.8/gems/usage-0.0.4/lib/Usage.rb:977:in
`initialize'
from tmp.rb:2
===
# Oops, bad case also caused me confusion.
===
require_gem 'Usage'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:251:in
`report_activate_error': Could not find RubyGem Usage (>= 0.0.0)
(Gem::LoadError)
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:188:in `activate'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:66:in
`active_gem_with_options'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:59:in `require_gem'
from tmp.rb:1
===
# Yay, the 'magic' combination that works!
===
require_gem 'usage'
p Usage
#=> Usage
p Usage.new( "foo" )
#=> PROGRAM: tmp.rb
#=> ERROR: too few arguments 1 expected, 0 given
#=>
#=> USAGE: tmp.rb foo