Attila Györffy

In search of a better experience.

Easily Enable Ruby Debugger Under Pow

I’ve finally figured out how to get Pow and ruby debug working together. It’s actually painfully straight forward and easy to set up. It’s also fully unobstrusive so it’s not going to be in anyone’s way who would be using Passenger or one of the standard Ruby servers like Webrick, Unicorn or Mongrel.

Pow lets you customize the environment in which worker processes run. Before an application boots, Pow attempts to execute two scripts — first .powrc and then .powenv — in the application’s root. Any environment variables exported from these scripts are passed along to Rack. So let’s make use of them and add the following into your project’s .powenv:

After that, ensure that the Ruby debugger is loaded. For Rails apps, it’s pretty straight forward, add ruby-debug into your Gemfile:

If you are ready, let’s actually make use of the debugger and run it in remote mode (yes, you can connect to it from a remote process!), ensuring that the remote mode is only set if we are running our app within Pow:

Make sure to restart your application (touch tmp/restart.txt). This will activate the debugger and run it in remote mode that will allow us to connect to from outside of the application’s process:

bundle exec rdebug -c

Add a debugger statement to your app and look how the debugger will pick it up, just like if it was a debugger call when running your app through the other application servers.

Simple as that.