Ruby 'require' error: cannot load such file

The Coding Monk picture The Coding Monk · Mar 17, 2012 · Viewed 237.4k times · Source

I've one file, main.rb with the following content:

require "tokenizer.rb"

The tokenizer.rb file is in the same directory and its content is:

class Tokenizer
    def self.tokenize(string)
        return string.split(" ")
    end
end

If i try to run main.rb I get the following error:

C:\Documents and Settings\my\src\folder>ruby main.rb

C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- tokenizer.rb (LoadError)
        from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require '
        from main.rb:1:in `<main>'

I just noticed that if I use load instead of require everything works fine. What may the problem be here?

Answer

Pascal picture Pascal · Mar 17, 2012

I just tried and it works with require "./tokenizer". Hope this helps.