From: Quintus Date: 2010-12-20T04:05:08+09:00 Subject: Re: Ruby 1.9.2 require issue Am 19.12.2010 19:17, schrieb Justin Whalley: > Hi, I'm new to Ruby. I am trying to use require to bring in methods.rb, > which is located on my hard drive in the Chapter05 folder. Getting the > following error: > > C:\Users\Whalley\Training\Ruby\Practice\Chapter05>ruby methods.rb > > C:\Users\Whalley\Training\Ruby\Practice\Chapter05>irb > irb(main):001:0> require "methods.rb" > LoadError: no such file to load -- methods.rb > from :29:in `require' > from :29:in `require' > from (irb):1 > from C:/Ruby192/bin/irb:12:in `
' > irb(main):002:0> > > > Anyone know what I can do to resolve this? I am following along with a > video tutorial that is using 1.8.?, and they are getting it returned as > "true" without any Load Errors. > > Any and all help will be much appreciated. > > Thanks. > From the official ruby-lang.org website (http://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9.2-released/): ============================================== It causes a LoadError $: doesn't include the current directory. Some script may need modifications to work properly. ============================================== I.e., "." is not one of the directories Ruby searches for scripts to require. Either use require_relative (which doesn't work in IRB, because there is no source file one could require relative to) or use require "./yourscript.rb" But PLEASE do not use that inside normal scripts, that's what require_relative is made for (and require_relative does some more than the code I gave above). Vale, Marvin