M
mr ra88it
Hello all,
I am under the impression that Kernel#require returns false if the
argument is already loaded. However, this morning I encountered
behavior that confused me.
I was trying to require the RedCloth gem, and I was doing it via irb.
First I tried:
irb(main):001:0> require 'redcloth'
LoadError: no such file to load -- redcloth
from (irb):1:in `require'
from (irb):1
from :0
but that didn't work because the gems were not loaded (at least I
think that's why I got an error). So, instead I did this:
irb(main):002:0> require 'rubygems'
=3D> true
irb(main):003:0> require 'redcloth'
=3D> false
So then I noticed that the last call to require returned false, which
made me think that requiring 'rubygems' was all that I needed to do
and RedCloth would automatically be loaded. I tested this by
restarting irb, but my assumption proved incorrect:
irb(main):001:0> require 'rubygems'
=3D> true
irb(main):002:0> RedCloth
NameError: uninitialized constant RedCloth
from (irb):2
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb:36=
5
irb(main):003:0> require 'redcloth'
=3D> false
irb(main):004:0> RedCloth
=3D> RedCloth
Can somebody help me understand why the RedCloth constant was not
initialized yet the call to require returns false? I hope I've
included enough information.
Incidentally, if I follow the instructions from the Pickaxe I get an error:
irb(main):001:0> require 'rubygems'
=3D> true
irb(main):002:0> require_gem 'redcloth'
Gem::LoadError: Could not find RubyGem redcloth (> 0.0.0)
Thanks for any input!
mr.ra88it
$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.3.0]
I am under the impression that Kernel#require returns false if the
argument is already loaded. However, this morning I encountered
behavior that confused me.
I was trying to require the RedCloth gem, and I was doing it via irb.
First I tried:
irb(main):001:0> require 'redcloth'
LoadError: no such file to load -- redcloth
from (irb):1:in `require'
from (irb):1
from :0
but that didn't work because the gems were not loaded (at least I
think that's why I got an error). So, instead I did this:
irb(main):002:0> require 'rubygems'
=3D> true
irb(main):003:0> require 'redcloth'
=3D> false
So then I noticed that the last call to require returned false, which
made me think that requiring 'rubygems' was all that I needed to do
and RedCloth would automatically be loaded. I tested this by
restarting irb, but my assumption proved incorrect:
irb(main):001:0> require 'rubygems'
=3D> true
irb(main):002:0> RedCloth
NameError: uninitialized constant RedCloth
from (irb):2
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb:36=
5
irb(main):003:0> require 'redcloth'
=3D> false
irb(main):004:0> RedCloth
=3D> RedCloth
Can somebody help me understand why the RedCloth constant was not
initialized yet the call to require returns false? I hope I've
included enough information.
Incidentally, if I follow the instructions from the Pickaxe I get an error:
irb(main):001:0> require 'rubygems'
=3D> true
irb(main):002:0> require_gem 'redcloth'
Gem::LoadError: Could not find RubyGem redcloth (> 0.0.0)
Thanks for any input!
mr.ra88it
$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.3.0]