Ruby 1.8.6 Windows Rails Project Template

Why doesn't Rails debugging work on Windows?


I was following the Rails tutorial, and everything was working like a champ until I got to the debugging part. The cmd window fires and sits there doing nothing. I understand Rails is all about a zen approach to building web apps, but isn't more supposed to happen?


Yes, the debugger should kick in. The problem is that shortly after the Rails tools were developed, Ruby 1.8.6 was released, and the Windows version of 1.8.6 fixed a bug. The bug was that the Dir#[] class method was accepting paths containing backslashes and quietly converting them to forward slashes, even though the documentation stated that the first argument is a regular expression. While Rubies 1.8.5 and earlier could have an expression like "Dir['c:\\foo\\bar\\*.rb'] and find all the Ruby libraries there, version 1.8.6 (and up I suppose) quietly returns an empty list.

The problem is that the Komodo debugger is extensible, and loads all its modules at run-time, by running Dir[] on a path based on its location. On Windows this path happens to contain backslashes. It didn't used to be a problem. It's fixed on the beta 4.2 versions of Komodo, but if you're trying to get the debugger to run on 4.1, you'll need to make this fix:

Find the file /lib/support/dbgp/rubylib/rdbgp/command.rb
load it in Komodo (or any other editor), find the load_dbgp_commands method,
and add the second line (the 'dir.gsub!' one):

def load_dbgp_commands
  dir = File.dirname(__FILE__)
  dir.gsub!(/\\/, '/') if RUBY_PLATFORM["-mswin"] # Allow for 64-bit, i686
  Dir[File.join(dir, 'commands', '*.rb')].each do |file|
    require file