Require -- looking in rubygems, not "."

irb
require “tr.rb”
LoadError: no such file to load – tr.rb
from internal:lib/rubygems/custom_require:29:in require' from <internal:lib/rubygems/custom_require>"29"inrequire’
from (irb):4
from C:/Ruby192/bin/irb:12:in `’

load “tr.rb”
Hello world!
=> true

File.exist? “tr.rb”
=> true

APP_ROOT = File.dirname(FILE)
=> “.”
require "#{APP_ROOT}/tr.rb
LoadError: no such file to load – ./practice
from…
(same stuff about ruby gems)

Trying to get started learning ruby. From what little I can tell, I
think Irb is only looking in rubygems instead of its own directory.
How do I fix that? This is my first attempt to learn any sort of
programming. Tyvm in advance for any help.

In Ruby 1.9.2, the current directory isn’t in the load path. Use
require_relative instead.

Thank you very much for the help. Could someone be so kind as to show an
example of what that code should look like? I tried the following
without success, all gave error messages.

with the command prompt in the desktop, so the prompt says "
C:\Users\Charles\Desktop , then started irb, so the prompt says
irb(main):001:0

require_relative ‘tr’
require_relative “tr”
require_relative “tr.rb”
require_relative “Desktop/tr”
require_relative “./tr.rb”
require_relative “./tr”
requre_relative “desktop/tr”

and so on, approximately 30 other variations, including substituting
backslashes for slashes, although in the past I have found that forward
slashes work in ruby on this computer while backslashes sometimes don’t.
I googled “require_relative” and found some examples, it looks like the
first one above should have worked. I also tried restarting the computer
and doing it all over again, then tried it on a laptop with winxp. None
of these worked either. Thanks in advance if someone has a minute to
answer this.

$ ls
tr.rb
$ irb

require_relative “tr”
#=> true

Thanks very much again. I really appreciate the help.

I tried typing the green line, but without the " > " symbol, then tried
it with the " > ". I tried typing the line

$ ls

and got an error message and tried it with a one instead of a letter l,
and tried all the other lines. I tried it on two other computers, in all
cases all I got was error messages. What am I doing wrong? Tyvm in
advance, and apologies for being so obtuse.

On Sun, Oct 9, 2011 at 9:51 PM, charles a.
[email protected]wrote:

advance, and apologies for being so obtuse.

“ls” is the Unix tool to list the contents of a directory. The
equivalent on
Windows is “dir”

On Sun, Oct 9, 2011 at 9:58 PM, Josh C. [email protected] wrote:

and tried all the other lines. I tried it on two other computers, in all
cases all I got was error messages. What am I doing wrong? Tyvm in
advance, and apologies for being so obtuse.

“ls” is the Unix tool to list the contents of a directory. The equivalent
on Windows is “dir”

The point he’s making is that there is a file in the current directory
named
“tr.rb”

On Sun, Oct 9, 2011 at 10:17 PM, charles a.
[email protected]wrote:

require_relative “tr”
Posted via http://www.ruby-forum.com/.

Here, I have made a video showing how to use it
http://vimeo.com/30294384

On Sun, Oct 9, 2011 at 11:28 PM, Josh C. [email protected]
wrote:

Here, I have made a video showing how to use it http://vimeo.com/30294384

Sorry, “technical difficulties”. Video is here instead

Thank you very much for taking time to reply sir. I am watching your
videos right now.

I still do not know what to type so to get the program to require that
file, so that any data or code in it, in the file tr.rb, and be able to
use it in the program.

recapping from above, I have tried typing at the irb prompt:

require_relative “tr”
require_relative “tr.rb”
require_relative “./tr”

and every variation I can think of.

So the question I mean to ask is what do I type at the irb prompt to
make that happen?
tyvm in advance and thanks all for your patience.

I cannot thank you enough. Josh C. rocks. Thanks also to Steve
Klabnik.

I thought I had tried < require ‘./tr’ > last night and it didn’t
work. It unquestionably does work this morning.

Scrolling up in the terminal window, which is still running, I see I did
try it last night and got error messages. I cannot explain that, but at
least it works now.

Thanks again.

Back to watching Josh’s videos.