I\'m having a really noob problem with importing files in Ruby. I\'m making a Ruby app in Windows XP. All the class files for the app are in \"C:/Documents/Prgm/Surveyor_R
I believe both of the previous posts are correct, just for different uses. In IRB use an absolute path with require
, with a file you can also use require
with an absolute path, or use require_relative
.
If you're trying to do this with rvmsudo, I found this worked for me:
rvmsudo irb -I '/Absolute/path/to/your/project'
it's damn dirty, but you can always do at the very first line:
$: << '.'
and off you go with pwd'ed require. It's quite useful for interactive/creative testing with IRB
None of these worked for me, but this did:
irb -I .
>require 'file'
=> true
Noticed the same behavior but my linux roots had me try:.\file.rb
and it loaded into the irb. Try explicitly declaring the current directory.
require './hede'
or
require_relative 'hede'
This works for me in both Ruby (1.9.3) and JRuby (1.7.x) on linux. I haven't tested it on windows.