Tuesday, May 15, 2007

FAQ: "script.rb" versus "script.rbw"

What's the difference between ".rb" and ".rbw" files?

As you probably know, Windows associates certain filename extensions with certain programs. For example, double-click on a file with the ".xls" filename extension, and the file will be opened in Microsoft Excel (if it is installed). Use the One-Click Ruby Installer, and your ".rb" and ".rbw" files will be associated with the Ruby interpreter, so that double-clicking on a Ruby script automatically runs the script in the Ruby interpreter.

But there are two Ruby interpreters installed on Windows, ruby.exe and rubyw.exe. ruby.exe is the standard interpreter, which runs your script in a command/console window. rubyw.exe is essentially the same as ruby.exe, but without the console window, so any output to the console (ie, 'puts' statements or error messages) will not be seen.

Files with a ".rb" filename extension are associated with ruby.exe, while files with a ".rbw" filename extension are associated with rubyw.exe. Double-click on a ".rb" file in Windows Explorer and the script will open up a console window -- while it is running. The console window will automatically close when the script stops running. Double-click on a ".rbw" file in Windows Explorer and the script will run, but with no console window (and therefore no error messages).

To ensure you see the necessary console output from your script, run it from a command prompt, or from an editor/IDE that includes an output window.

For more answers to Frequently-Asked Questions, check out posts with the faq tag.

Thanks for stopping by!

2 comments:

Chris said...

Thanks! This helped me out.

Anonymous said...

Thank you for your help.