Trying to load a .rb file in irb

I am trying to load a ruby program into irb and it will not load.

i have tried typing:

load ' personal_chef.rb'

load 'personal_chef.rb '

As well as using the entire path name and I always get the same message:

LoadError: cannot load such file

         from<irb>:1:in 'load'
         from<irb>:1

I have ruby version 2.00 and its on windows 7.

Any ideas? I feel like this is a simple problem like spacing or
something, but I just can't figure it out...

···

--
Posted via http://www.ruby-forum.com/.

why do you put whitespace in the path?

try

   load 'personal_chef.rb'

···

Am 13.06.2013 22:35, schrieb Eric D.:

I am trying to load a ruby program into irb and it will not load.

i have tried typing:

load ' personal_chef.rb'

load 'personal_chef.rb '

--
<https://github.com/stomar/&gt;

Tried it exactly as you wrote it and the same error message arose.

I put the white space in because one of the other forums said that some
of the text editors(sublime, textmate etc. add white spaces)

···

--
Posted via http://www.ruby-forum.com/.

Try Dir.pwd to see where irb is looking for the file. You might need the
full path.

···

--
Posted via http://www.ruby-forum.com/.

I did that it says C:/Users/Eric.

Is there anyway I can change the directory to some other location?

···

--
Posted via http://www.ruby-forum.com/.

Make sure you start irb from the directory where the file is located.
You can list the files in that directory with

   Dir['*']

If you see your file on this list, load 'file.rb' should work.

Otherwise you need to specify the full path.

···

Am 13.06.2013 22:35, schrieb Eric D.:

I am trying to load a ruby program into irb and it will not load.

--
<https://github.com/stomar/&gt;

Dir.chdir should change the path to whatever you specify. If you want to
change the starting path you'll need to launch irb with the command
prompt when you're in your chosen folder, or add a command to your
.irbrc file.

···

--
Posted via http://www.ruby-forum.com/.

The directory change worked! Thank you both for your help. One question
though, when I try to load a text file from a program in ruby it says

undefined method `each' for "text.txt":String (NoMethodError).

My code looks like this:

File.open ("text.txt").each {|line| puts line}

Both the text.txt and the program loading it are in the same directory.

Any suggestions?

···

--
Posted via http://www.ruby-forum.com/.

Never mind i figured it out. Thank you guys! Great forum!

···

--
Posted via http://www.ruby-forum.com/.

I'd use
File.foreach( 'text.txt' ) {|line| puts line }

···

--
Posted via http://www.ruby-forum.com/.

Apologies. On the loading issue that I eluded to early it was the
spacing mentioned in unknown (Guest)'s post.

···

--
Posted via http://www.ruby-forum.com/.

File.open("text.txt").each {|line| puts line }

Never put a space between method name and '('.

BTW. When you figure it out by yourself, you should also include
      the solution in your "Never mind" post. In case other people
      have a similar problem.

···

Am 18.06.2013 23:27, schrieb Eric D.:

though, when I try to load a text file from a program in ruby it says

undefined method `each' for "text.txt":String (NoMethodError).

My code looks like this:

File.open ("text.txt").each {|line| puts line}

--
<https://github.com/stomar/&gt;