# Require files namespace!

**URL:** <https://www.ruby-forum.com/t/require-files-namespace/182365>\
**Category:** Ruby\
**Created:** [January 27, 2010, 2:23am UTC](https://www.ruby-forum.com/t/require-files-namespace/182365 "2010-01-27T02:23:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![advenk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ebca7d/32.png) [@advenk](https://www.ruby-forum.com/u/advenk)\
**Post date:** [January 27, 2010, 2:23am UTC](https://www.ruby-forum.com/t/require-files-namespace/182365/1 "2010-01-27T02:23:38Z")

</div>

Hi,

this seems to be bugging me for a bit now.

I am creating a gem with tool.rb in the /lib folder

module Tool

require ‘tool/word.rb’  
require ‘tool/sentence.rb’

end

and the word.rb is

class Tool::Word

def methods…

end

and sentence.rb is

class Tool::Sentence

def methods…

end

and i am using irb

> > require ‘tool.rb’  
> > NameError: undefined local variable or method `tool’ for main:Object  
> > from (irb):1

I am not sure how to include the files!

I appreciate your help.  
Thanks!

---

<div class="post-metadata">

**Author:** ![advenk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ebca7d/32.png) [@advenk](https://www.ruby-forum.com/u/advenk)\
**Post date:** [January 27, 2010, 3:46am UTC](https://www.ruby-forum.com/t/require-files-namespace/182365/2 "2010-01-27T03:46:38Z")

</div>

> > > require ‘tool.rb’  
> > > NameError: undefined local variable or method `tool’ for main:Object  
> > > from (irb):1
> 
> I am not sure how to include the files!

What’s the full backtrace? (chances are you have a stray “tool” in there  
somewhere)

---

<div class="post-metadata">

**Author:** ![advenk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ebca7d/32.png) [@advenk](https://www.ruby-forum.com/u/advenk)\
**Post date:** [January 27, 2010, 8:48am UTC](https://www.ruby-forum.com/t/require-files-namespace/182365/3 "2010-01-27T08:48:04Z")

</div>

Roger P. wrote:

> What’s the full backtrace? (chances are you have a stray “tool” in there  
> somewhere)

Yes, it’s saying that you’re using “tool” (lower-case t) by itself.

If I take just the code you posted, then it works fine for me under  
ruby-1.8.7 and Ubuntu Karmic:

$ ls -lR  
.:  
total 4  
drwxr-xr-x 3 brian brian 4096 2010-01-27 07:45 lib

./lib:  
total 8  
drwxr-xr-x 2 brian brian 4096 2010-01-27 07:45 tool  
-rw-r–r-- 1 brian brian 68 2010-01-27 07:44 tool.rb

./lib/tool:  
total 8  
-rw-r–r-- 1 brian brian 25 2010-01-27 07:44 sentence.rb  
-rw-r–r-- 1 brian brian 21 2010-01-27 07:44 word.rb

$ head $(find . -type f)  
==\> ./lib/tool/word.rb \<==  
class Tool::Word  
end

==\> ./lib/tool/sentence.rb \<==  
class Tool::Sentence  
end

==\> ./lib/tool.rb \<==  
module Tool

require ‘tool/word.rb’  
require ‘tool/sentence.rb’

end

$ irb -Ilib --simple-prompt

> > require ‘tool.rb’  
> > =\> true
> 
> >

(However, note that it is preferred if you require ‘tool’ rather than  
require ‘tool.rb’)

---

<div class="post-metadata">

**Author:** ![advenk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ebca7d/32.png) [@advenk](https://www.ruby-forum.com/u/advenk)\
**Post date:** [January 28, 2010, 2:41am UTC](https://www.ruby-forum.com/t/require-files-namespace/182365/4 "2010-01-28T02:41:07Z")

</div>

Thanks Brian and Roger!

Well, this one was weird, i checked out for a missing or extra tool and  
did not seem to find anything odd.

I simply quit the terminal and restarted it, and it worked like a charm,  
yeah sometimes it just works that way.

Thanks anyway though!!
