# Require is not the same in irb as in ruby?

**URL:** <https://www.ruby-forum.com/t/require-is-not-the-same-in-irb-as-in-ruby/141308>\
**Category:** Ruby\
**Created:** [June 24, 2008, 4:23pm UTC](https://www.ruby-forum.com/t/require-is-not-the-same-in-irb-as-in-ruby/141308 "2008-06-24T16:23:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gremio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@gremio](https://www.ruby-forum.com/u/gremio)\
**Post date:** [June 24, 2008, 4:23pm UTC](https://www.ruby-forum.com/t/require-is-not-the-same-in-irb-as-in-ruby/141308/1 "2008-06-24T16:23:38Z")

</div>

$ irb  
irb(main):001:0\> require ‘rubygems’  
=\> true  
irb(main):002:0\> require ‘builder’  
=\> true  
irb(main):003:0\> ^D

All well and good. Now:

$ cat \> foo.rb  
#!/usr/bin/ruby  
require ‘rubygems’  
require ‘builder’  
^D  
$ chmod +x foo.rb  
$ foo.rb  
/usr/local/lib/site\_ruby/1.8/rubygems/custom\_require.rb:21:in  
`require__': no such file to load -- builder (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in`require’  
from ./foo.rb:3

What’s going on here? I only experience this with builder. Other  
modules seem fine. Incidentally, there’s a builder.rb at  
/usr/local/lib/site\_ruby/1.8/rubygems/builder.rb  
right next to the custom\_require.rb that fails to find it.

Thanks for any insights!  
Grem

---

<div class="post-metadata">

**Author:** ![gremio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@gremio](https://www.ruby-forum.com/u/gremio)\
**Post date:** [June 24, 2008, 4:28pm UTC](https://www.ruby-forum.com/t/require-is-not-the-same-in-irb-as-in-ruby/141308/2 "2008-06-24T16:28:53Z")

</div>

Interesting…

I guessed that maybe the fact that I was using /usr/bin/ruby and there  
was a separate /usr/local/bin/ruby might be a problem. They are the  
same version  
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]

and in fact, one turns out to be a symlink to the other(!) but using  
/usr/bin/ruby in the shebang fails, while using /usr/local/bin/ruby in  
the shebang succeeds.

Any ideas?

Thanks,  
Grem

---

<div class="post-metadata">

**Author:** ![gremio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@gremio](https://www.ruby-forum.com/u/gremio)\
**Post date:** [June 24, 2008, 8:19pm UTC](https://www.ruby-forum.com/t/require-is-not-the-same-in-irb-as-in-ruby/141308/3 "2008-06-24T20:19:14Z")

</div>

Gregory M. wrote:

> Any ideas?
> 
> Thanks,  
> Grem

Print the value of $: to determine the directories in which Ruby will  
look for libraries. Those directories are largely determined by the  
directory in which Ruby is installed at the time Ruby is installed. If  
Ruby is actually installed in /usr/local then it won’t search for  
libraries in /usr.

Good luck!
