Ruby Debug Not Working

I installed ruby-debug using this command:   sudo gem install ruby-debug -y

and then added the line to config/environments/development.rb:   require "ruby-debug"

I restarted webrick and put 'debugger' in my code and tried to access the page with the debugger command, but it didn't do anything. I've tried several times and restarted webrick, to no avail.

rails 2.1.1 ruby1.8.6 ruby-debug-0.10.3

Eric

Eric J wrote:

I installed ruby-debug using this command:   sudo gem install ruby-debug -y

and then added the line to config/environments/development.rb:   require "ruby-debug"

I restarted webrick and put 'debugger' in my code and tried to access the page with the debugger command, but it didn't do anything. I've tried several times and restarted webrick, to no avail.

rails 2.1.1 ruby1.8.6 ruby-debug-0.10.3

Eric

Where did you put the require statement and where did you put the debugger method for instance?

I put require "ruby-debug" at the top of config/environments/ development.rb. I just tried moving it to the bottom of the file and that didn't seem to help either.

I put the command 'debugger' at the start of one of my controller methods, so it should hit the controller and then call debugger.

I think you need mongrel for debug try script/server mongrel

I installed mongrel and tried it, but no debugging luck. I tried adding Debugger.start after the 'require "ruby-debug"'.

Is there a debug flag that you need to add to the start up command?

Well it started working, so maybe it was mongrel!

Thanks for your help guys.

Eric J wrote:

I installed mongrel and tried it, but no debugging luck. I tried adding Debugger.start after the 'require "ruby-debug"'.

Is there a debug flag that you need to add to the start up command?

script/server --debugger

You can debug with webrick as well: as James Byrne stated, you must add --debugger when you run the webrick server. Also you don't actually need to add the require statement neither Debugger.start if you are using rails 2.x . 'debug' keywords will also be ignored if you aren't running server with '--debugger', though it can be a danger in rails 1.x apps; 'debug' statements will throw an error unless ' require "ruby-debug" ' is added.. and even in that case the server, at least webrick, will stop on the debug breakpoint even if you run a production server.

James Byrne wrote:

Eric J wrote:

I installed mongrel and tried it, but no debugging luck. I tried adding Debugger.start after the 'require "ruby-debug"'.

Is there a debug flag that you need to add to the start up command?

script/server --debugger

This is the command correct ...!!!

$ rdebug ./script/server would help (Have to enter "c" after starting)