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 internal:lib/rubygems/custom_require:29:in require' from <internal:lib/rubygems/custom_require>: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.
Am 19.12.2010 19:17, schrieb Justin W.:
from <internal:lib/rubygems/custom_require>:29:in `require'
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
On Dec 19, 3:17pm, Justin W. [email protected] wrote:
from <internal:lib/rubygems/custom_require>:29:in `require'
from (irb):1
from C:/Ruby192/bin/irb:12:in `<main>'
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.
http://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9.2-released/
FAQ Section:
“It causes a LoadError
$: doesn’t include the current directory. Some script may need
modifications to work properly.”
The current directory is no longer included in the $LOAD_PATH ($:)
You need to include it to have the compatibility behavior of 1.8.x
irb -I.
or ruby -I. script.rb