I am having the following error when I try to require ‘test/unit’, on
Mac OS X using rbenv with rub 1.9.3, has anyone seen this error before ?
if so can you tell me how to fix it.
/Users/mxruby/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- experiment01 (LoadError) from /Users/mxruby/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire’
from test_experiment01.rb:3:in `’
`require’: cannot load such file – experiment01 (LoadError)
No, you have an error when you try to require ‘experiment01’, not
‘test/unit’. Look at your load path.
It works with “require_relative ‘experiment01’”, but I am sure why it
didn’t work with just require.
Ruby looks for files in a list of directories called $LOAD_PATH. If your
file isn’t in one of these directories ‘require’ won’t find it. If you
puts $LOAD_PATH you can see the list of directories.
It works with “require_relative ‘experiment01’”, but I am sure why it
didn’t work with just require.
In case you just switched from 1.8 to 1.9:
The behaviour of require changed in 1.9.2, since the path of
the requiring file is no longer included in the $LOAD_PATH.
Thus, to require a file in the same directory,
you need to e.g. use either