# Question about require

**URL:** <https://www.ruby-forum.com/t/question-about-require/52403>\
**Category:** Ruby\
**Created:** [January 13, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/question-about-require/52403 "2006-01-13T17:52:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_ra88it](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@mr\_ra88it](https://www.ruby-forum.com/u/mr_ra88it)\
**Post date:** [January 13, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/question-about-require/52403/1 "2006-01-13T17:52:46Z")

</div>

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’  
=\> true  
irb(main):003:0\> require ‘redcloth’  
=\> 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’  
=\> 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:365  
irb(main):003:0\> require ‘redcloth’  
=\> false  
irb(main):004:0\> RedCloth  
=\> 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’  
=\> 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]

---

<div class="post-metadata">

**Author:** ![mr\_ra88it](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@mr\_ra88it](https://www.ruby-forum.com/u/mr_ra88it)\
**Post date:** [January 13, 2006, 7:51pm UTC](https://www.ruby-forum.com/t/question-about-require/52403/2 "2006-01-13T19:51:35Z")

</div>

mr ra88it wrote:

> 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’  
> =\> true  
> irb(main):003:0\> require ‘redcloth’  
> =\> false

See Ruby-talk:174387  
([http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/174387](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/174387))

> Incidentally, if I follow the instructions from the Pickaxe I get an  
> error:
> 
> irb(main):001:0\> require ‘rubygems’  
> =\> true  
> irb(main):002:0\> require\_gem ‘redcloth’  
> Gem::LoadError: Could not find RubyGem redcloth (\> 0.0.0)

Because the name of the gem is ‘RedCloth’, not ‘redcloth’. Yes, case  
matters when requiring gems. (Probably shouldn’t … I’ll make a note  
of that).

–  
– Jim W.

---

<div class="post-metadata">

**Author:** ![mr\_ra88it](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@mr\_ra88it](https://www.ruby-forum.com/u/mr_ra88it)\
**Post date:** [January 13, 2006, 10:36pm UTC](https://www.ruby-forum.com/t/question-about-require/52403/3 "2006-01-13T22:36:47Z")

</div>

On Fri, 13 Jan 2006 19:51:58 +0100, Jim W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Because the name of the gem is ‘RedCloth’, not ‘redcloth’. Yes, case  
> matters when requiring gems. (Probably shouldn’t … I’ll make a note  
> of that).
> 
> –  
> – Jim W.

Three hoolays for systems that aren’t arbitrarily case-sensitive.

David V.

---

<div class="post-metadata">

**Author:** ![mr\_ra88it](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@mr\_ra88it](https://www.ruby-forum.com/u/mr_ra88it)\
**Post date:** [January 13, 2006, 11:25pm UTC](https://www.ruby-forum.com/t/question-about-require/52403/4 "2006-01-13T23:25:22Z")

</div>

On Fri, 13 Jan 2006 23:03:35 +0100, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Quoting David V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > Three hoolays for systems that aren’t arbitrarily case-sensitive.
> 
> In which locale’s notion of case? 😉
> 
> -mental

Oi, the Titanic of my ramble is getting ready to hit a iceberg. But,  
here  
goes: in a locale AND context where case distinction isn’t semantically  
significant or actually helpful. Like programming language libraries  
named  
in languages using the latin alphabet and using capital letters for  
reasons of historical conventions rather than to disambiguate the  
meaning  
of words _pant_. Unless someone tells me what would come from having  
distinct “redcloth” and “RedCloth” libs aside from sadistically enjoying  
the torment of people that confuse them.

Another example: filesystem filename lookup. _dons his +5  
Asbestos Plate Mail, +80% flame resistance, and prepares to duck objects  
thrown at him_

David V.

---

<div class="post-metadata">

**Author:** ![mr\_ra88it](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@mr\_ra88it](https://www.ruby-forum.com/u/mr_ra88it)\
**Post date:** [January 13, 2006, 11:04pm UTC](https://www.ruby-forum.com/t/question-about-require/52403/5 "2006-01-13T23:04:03Z")

</div>

Quoting David V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Three hoolays for systems that aren’t arbitrarily case-sensitive.

In which locale’s notion of case? 😉

-mental

---

<div class="post-metadata">

**Author:** ![mr\_ra88it](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@mr\_ra88it](https://www.ruby-forum.com/u/mr_ra88it)\
**Post date:** [January 14, 2006, 1:17am UTC](https://www.ruby-forum.com/t/question-about-require/52403/6 "2006-01-14T01:17:09Z")

</div>

Thoroughly entertaining! 🙂

On 1/13/06, David V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> Another example: filesystem filename lookup. _dons his +5  
> Asbestos Plate Mail, +80% flame resistance, and prepares to duck objects  
> thrown at him_
> 
> David V.

## –

‘There was an owl lived in an oak.  
The more he heard, the less he spoke.  
The less he spoke, the more he heard.’

Christian L.  
removed\_email\_address@domain.invalid
