views:

330

answers:

2

Hi,

I installed ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] on my Windows XP laptop.

When I run ruby.exe I get a blank DOS Shell window. No expected "irb(main):001:0>" at the top left of the command prompt. I can type into the shell but, any code I type in actually does anything when pressing enter.

I should mention that I can start IRB from the cmd.exe DOS shell and it functions perfectly. Additionally I have the System Variables path set to c:\ruby\bin so I know that is ok.

Any ideas what could be going wrong and how to fix it?

+2  A: 

ruby.exe != irb.bat

irb is a batch file that runs ruby.exe as an interactive shell. It actually passes a file called "irb" (no extension) as the parameter. You want to be running irb.

Ed Swangren
thanks for the clues. i figured it out. but to be specific, you meant to write "ruby.exe != irb.bat" i'm sure as there is no irb.exe.
You're right, fixed
Ed Swangren
+1  A: 

More precisely, running ruby by itself still gives you a ruby interpreter, but you'll miss these features of IRB: The interactive prompt with line editing, immediate execution, and automatic printing of the result.

For example:

C:\> ruby
puts "hello"
"test string"

Press Ctrl+Z and then Enter. It outputs

hello

Ctrl+Z send an "end of file" signal to the interpreter. Unlike IRB, it doesn't consume input one line at a time by default, so it waited to output "hello". The "test string" wasn't displayed at all.

P.S. Conversely, you can also pass the name of a file to IRB (just irb hello.rb), and it will run it as if you typed it in, displaying each line of code and the result as it goes.

jleedev
oh i never knew you could rub ruby by itself in the cmd.exe command prompt. doesn't seem efficient or fun though. by the way, how do you run a .rb file in IRB?