I’m trying to do a very simple require method with two files.
puts “Hello, from a.rb.”
puts “Hello from b.rb”
puts “Hello again from b.rb”
Both are located in the same directory.
When I run b.rb, however, I get the following error:
require': cannot load such file -- a.rb (LoadError) from /Users/josephinechang/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
from b.rb:1:in `’”
I’m not sure what the problem is. Thanks in advance to anyone who can
Use require_relative for a require with relative paths. Otherwise you’ll
need to provide the full path, or add that directory to your PATH.
For your own messing around, you can also do:
The problem with that is it assumes you are running the program from the
directory that contains a.rb–if that is not be the case, then
require won’t be able to find the file…hence the need for
I am having the identical problem as Anthony Chang. Files a.rb and b.rb
are in the same directory, but “require” is coming back with the same
error message Anthony described.
require': cannot load such file -- a (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
from b.rb:1:in `’
The error first occurred after I upgrading my OS which included Ruby
I tried replacing require with require_relevant and received the
following error msg
<main>': undefined methodrequire_relevant’ for main:Object