Unable to require 'test/unit'

Hi All

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.

Thanks

/ruby_sandbox/ruby_best_practice/unit_test_experiment$> ruby
test_experiment01.rb

/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:in
`require'
  from test_experiment01.rb:3:in `<main>'

···

--
Posted via http://www.ruby-forum.com/.

No, you have an error when you try to require 'experiment01', not 'test/unit'. Look at your load path.

···

On Aug 4, 2012, at 10:35 , Ja Tse <lists@ruby-forum.com> wrote:

Hi All

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.

/ruby_sandbox/ruby_best_practice/unit_test_experiment$> ruby
test_experiment01.rb

/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)

maybe you used require 'experiment01'
instead of require_relative 'experiment01'?

···

Am 04.08.2012 19:35, schrieb Ja Tse:

Hi All

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.

Thanks

/ruby_sandbox/ruby_best_practice/unit_test_experiment$> ruby
test_experiment01.rb

/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:in
`require'
   from test_experiment01.rb:3:in `<main>'

--
<https://github.com/stomar/&gt;

It works with "require_relative 'experiment01'", but I am sure why it
didn't work with just require.

···

--
Posted via http://www.ruby-forum.com/.

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.

Henry

···

On 6/08/2012, at 6:53 AM, Ja Tse wrote:

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

   require './myfile'

or

   require_relative 'myfile'

See also <Module: Kernel (Ruby 1.9.3);

···

Am 05.08.2012 20:53, schrieb Ja Tse:

It works with "require_relative 'experiment01'", but I am sure why it
didn't work with just require.

--
<https://github.com/stomar/&gt;