Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't IRB locate the file to "require"?

Tags:

ruby

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?

like image 418
Test Test Avatar asked Dec 20 '22 11:12

Test Test


1 Answers

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.

like image 89
Zajn Avatar answered Feb 01 '23 01:02

Zajn