I have a file in a directory test/.
The file is "test.rb".
When I start IRB and type:
require 'test'
require_relative 'test'
It returns:
LoadError: cannot load such file -- test
and:
LoadError: cannot infer basepath
Is my Ruby messed up?
I have a file in a directory test/.
The file is "test.rb".
When I start IRB and type:
require 'test'
require_relative 'test'
It returns:
LoadError: cannot load such file -- test
and:
LoadError: cannot infer basepath
Is my Ruby messed up?
Try require './test'
I think newer versions of Ruby removed the current directory from the Ruby path.
Edit:
Also, check out the answer to "Why isn't current directory on my Ruby path?" for an explanation why require_relative doesn't work in irb.
The file which is to be required should be present in the same directory as interactive ruby is present (for windows). For eg, I have installed ruby in C:\ . Hence, my interactive ruby is in C:\Ruby22\bin. So, paste the required file and type require './file' in the 'interactive ruby'.