Possible Duplicate:
Why does Ruby 1.9.2 remove “.” from LOAD_PATH, and what's the alternative?
Require command not working within bash irb on Snow Leopard
Rubyrequire
call fails on custom code
I'm running:
- OS X 10.6.8
- RVM 1.12.3 with Ruby 1.9.3
Let's say I have the following files in a directory:
a.rb
require 'b'
puts message_from_b
b.rb
def message_from_b
"foo"
end
I get the following LoadError upon running a.rb:
/Users/Alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- b (LoadError)
However, if I replace line 1 of a.rb with require './b'
, it works fine.
When looking at other people's Ruby code, it seems that they don't need to specify the current directory for it to require a file in the same directory.
So, why do I have to do that? Is it something to do with my RVM install?