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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With