Why, when I run ruby.exe / IRB, all I get is an empty DOS shell?

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

When I run ruby.exe, I get a blank DOS shell window. There is no expected "irb (main): 001: 0>" at the top left of the command line. I can type into the shell, but whatever code I type actually does anything when I hit enter.

I should mention that I can run IRB from CMOS shell cmd.exe and it works great. Also, I have the system variables path set to c: \ ruby ​​\ bin, so I know everything is fine.

Any ideas what might be wrong and how to fix this?

+2


source to share


2 answers


ruby.exe! = irb.bat



irb is a batch file that runs ruby.exe as an interactive shell. It actually passes a file named irb (no extension) as a parameter. You want to run irb.

+3


source


More precisely, launching ruby

by itself still gives you a ruby ​​interpreter, but you miss out on these IRB functions: interactive prompt with line editing, immediate execution, and automatic printing of the result.

For example:

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

      

Click Ctrl+Zand then Enter. It outputs



hello

      

Ctrl + Z sends an end-of-file signal to the interpreter. Unlike IRB, it does not consume one line at a time by default, so it was expecting a "hello" output. The "test string" was not displayed at all.

PS Conversely, you can also pass the filename to the IRB (simple irb hello.rb

) and it will run it as if you had typed it, specifying each line of code and the result as it goes.

+2


source







All Articles