Debugging rails in an IDE?

Excuse the naivety of this post

I'm coming from a Windows C++ background where I can attach an IDE debugger to a process on a web server, and so catch and debug errors in web server extensions.

Is there a way to use one of the Ruby IDE debuggers with Rails? I feel I'd be much more productive this way, but can't work out how I can grab the process and attach to an IDE debugger.

Should I be using WEbrick rather than apache, and run the whole thing under a debugger? This is where I get completely lost...

What does everyone else do?

TVM

Pete

Pete Johnson wrote:

I'm coming from a Windows C++ background where I can attach an IDE debugger to a process on a web server, and so catch and debug errors in web server extensions.

Is there a way to use one of the Ruby IDE debuggers with Rails? I feel I'd be much more productive this way, but can't work out how I can grab the process and attach to an IDE debugger.

Should I be using WEbrick rather than apache, and run the whole thing under a debugger? This is where I get completely lost...

The latest versions of breakpoint.rb contain facilities for DRb debugging which allows you to set a breakpoint in your web framework and attach an irb session from within a terminal. I have attached the most up-to-date version to this email. There's still a few issues (I'd like to have a way of executing pieces of code from within the irb session on the client-side and the whole assume() naming controversy) to be resolved until this can be merged into dev-utils but I'm pretty sure they can be resolved soon.

See the documentation (inside source, can be extracted with RDoc) for how to use this. If you have an specific questions or suggestions I'd love to hear about them.

License is the same as Ruby in case it matters.

breakpoint_client.rb (2.24 KB)

binding_of_caller.rb (2.54 KB)

breakpoint.rb (9.57 KB)

I've been really digging the ArachnoRuby IDE lately
(http://www.ruby-ide.com). It's still beta, and it has a few quirks at
this point (mainly related to the way it auto-indents code), but it's
the only full-fledged Ruby IDE out there that's really worth the
trouble at this point.

You can debug Rails apps with ArachnoRuby. It's not 100%
straight-forward, though. First, if you're using Gems, you'll have to
edit the ArachnoRuby preferences and add the GEM_PATH variable to
point to your gems directory. I honestly don't know _why_ this is
necessary (as in, why ArachnoRuby doesn't detect this automatically,
since the regular ruby interpreter has no problem with it), but if you
don't, you'll get errors about missing gems.

Then you can simply set up a debug target using dispatch.rb and set up
GET CGI variables for controller, action, etc. It has an interface for
setting all of this up.

I'd recommend checking it out. If you have any problems getting the
debugging to work, I'm happy to help as far as I'm able.

···

On Thu, 18 Nov 2004 09:28:14 +0900, Pete Johnson <news19@tildium.com> wrote:

Is there a way to use one of the Ruby IDE debuggers with Rails? I
feel I'd be much more productive this way, but can't work out how
   I can grab the process and attach to an IDE debugger.

--
Regards,
John Wilger

-----------
Alice came to a fork in the road. "Which road do I take?" she asked.
"Where do you want to go?" responded the Cheshire cat.
"I don't know," Alice answered.
"Then," said the cat, "it doesn't matter."
- Lewis Carrol, Alice in Wonderland

Hello John,

I've been really digging the ArachnoRuby IDE lately
(http://www.ruby-ide.com). It's still beta, and it has a few quirks at
this point (mainly related to the way it auto-indents code), but it's

Can you please give me some code snippets where the auto-indents are
wrong. Also do you use version 3.2 ? I fixed some of the auto-indent
bugs there and now i think it only fails on complicated quoted strings.

You can debug Rails apps with ArachnoRuby. It's not 100%
straight-forward, though. First, if you're using Gems, you'll have to
edit the ArachnoRuby preferences and add the GEM_PATH variable to
point to your gems directory. I honestly don't know _why_ this is
necessary (as in, why ArachnoRuby doesn't detect this automatically,
since the regular ruby interpreter has no problem with it), but if you
don't, you'll get errors about missing gems.

I think the reason is that the system environment is not passed to cgi
scripts. This is because it is the way apache is normally setup and i
wanted the debugging environment to be as close to a normal setup as
possible. In the "Project Settings" on the "General - Environment
Variables" there is a "Pass System Environment to CGI scripts" option.
This must be set.

Maybe i should set this option by default ?

···

--
Best regards, emailto: scholz at scriptolutions dot com
Lothar Scholz http://www.ruby-ide.com
CTO Scriptolutions Ruby, PHP, Python IDE 's

Lothar Scholz said:

Hello John,

> I've been really digging the ArachnoRuby IDE lately
> (http://www.ruby-ide.com). It's still beta, and it has a few quirks at
> this point (mainly related to the way it auto-indents code), but it's

Can you please give me some code snippets where the auto-indents are
wrong. Also do you use version 3.2 ? I fixed some of the auto-indent
bugs there and now i think it only fails on complicated quoted strings.

Yeah, long quoted strings using %{ ... } tend to confuse it. Also,
continued lines don't seem to be indented as I expect. For example..

   x = a +
   b # <== I expected continued lines to be indented.

Also, long here documents are modified by indent region/indent file.
Since here documents are strings, I would expect them to be left alone
during the reformatting process. For example, running indent-selection on
the following code ...

    class_eval <<-EOS
      def #{sym}() @#{sym} end
      def #{sym}=(value)
  self.class.validate(:#{sym}, value)
  @#{sym} = value
      end
    EOS

... has the following effect ...

    class_eval <<-EOS
    def #{sym}() @#{sym} end
    def #{sym}=(value)
    self.class.validate(:#{sym}, value)
    @#{sym} = value
    end
    EOS

But these are minor complaints. All in all, from the little I have played
with it, it is a very nice looking package. The user interaction is nice
and crisp, windows open immediately with no delay. The artwork is well
done and attractive. Nice attention to detail. I particularly like
things like the "display this buffer in a browser" command. Good job!

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

Hello Jim,

Yeah, long quoted strings using %{ ... } tend to confuse it.

The quoting rules of ruby are unfortunately the most complicated i've
ever seen. And often you can only find out if a '%(' starts a string
or is a modulo operation with some argument only after doing a full,
exact expression parse. For the moment i'm not really motivated to do
this.

Also,
continued lines don't seem to be indented as I expect. For example..

   x = a +
   b # <== I expected continued lines to be indented.

In this case it's easy but there can be much more complex cases.
Is the emacs mode doing this correctly ? Maybe i can find some hints
there how to handle this situation better. I'm not sure if the
result justifies the huge amout of time it costs to fix this, since at
the moment everybody is waiting for code insight things like this.
But i will put a line about this to my improvements list.

Also, long here documents are modified by indent region/indent file.
Since here documents are strings, I would expect them to be left alone
during the reformatting process. For example, running indent-selection on
the following code ...

You are right, this is a clear bug. I will fix it.

···

--
Best regards, emailto: scholz at scriptolutions dot com
Lothar Scholz http://www.ruby-ide.com
CTO Scriptolutions Ruby, PHP, Python IDE 's