ruby-debug with Pow -- breakpoints never hit
Asked Answered
T

2

8

I'm trying to use ruby-debug with Pow. Rails 3 app.

I have done everything here: https://gist.github.com/1098830

I've restarted the server and machine several times. I can get rdebug to connect:

→ rdebug -c
Connected.

but it never stops at the breakpoints.

Any idea what could be going on? I got it to hit a few breakpoints a few hours ago, and not since.

controller

  def index
    debugger
    ...
  end

Gemfile

gem 'ruby-debug19', :require => 'ruby-debug'

development.rb

EG::Application.configure do
  ...
  require 'ruby-debug'
  Debugger.start_remote
  Debugger.settings[:autoeval] = true
  puts "=> Debugger enabled"
end
Tillion answered 25/1, 2012 at 0:45 Comment(2)
does it works without pow? which version of ruby are you using?Ecesis
yes, it works under webrick and passenger. ruby 1.9.2p290Tillion
P
8

This happens because Pow runs two worker processes as default, and rdebug only connects to one of them. If the other process serves the request, then no dice. The solution is to force Pow to run a single worker process, as follows:

  1. Edit ~/.powconfig to contain export POW_WORKERS=1
  2. Restart Pow itself by killing the Pow process

You should now hit your breakpoint on every request.

Petitioner answered 6/3, 2012 at 16:52 Comment(0)
R
2

Update Sept '12

I switched to the debugger gem - a fork of ruby-debug19 with better support for ruby 1.9.2/3

This also allowed to simplify the configuration for remote-debugging in development.rb. I hit the breakpoint every single time and have no hanging processes.

require 'debugger'
Debugger.start_remote

Original Answer

Try enabling wait_connection (and restart pow)

require 'ruby-debug'
Debugger.wait_connection = true
Debugger.start_remote
Debugger.settings[:autoeval] = true
puts "=> Debugger enabled"

reload source is also nice: Debugger.settings[:reload_source_on_change] = true

Romany answered 27/1, 2012 at 12:5 Comment(2)
"Debugger.wait_connection = true" will hang up your process, so be careful.Orlene
True that, I noticed that some requests take "forever" (i.e. 10-15 seconds) but at least it did the trick of hitting the debugger every time. It still ok for me as I hardly use it anyway, namely only when the code lives in a callback which points to the *.dev URI.Romany

© 2022 - 2024 — McMap. All rights reserved.