Using rack-debug with Ruby 1.9.2 and Rails 3

At my company, we run all our apps in Passenger (production and dev), and having a debugger that can attach to Passenger is very useful.
When we were still on a Ruby 1.8.x/Rails 2.x stack, David Dollar’s excellent rack-debug worked like a charm.

However, it depends on ruby-debug which is incompatible with 1.9.x. I did a quick fork of rack-debug to conditionally depend on ruby-debug19, but when I submitted the pull request, ddollar rightly pointed out that the conditional logic in creating the gemspec wouldn’t work. It would only make a version of the gem for the ruby version on the machine that cut the gem, and there’s no way to have conditionals in gemspecs b/c they are YAML. He did however point me to a 1.9.x version he cut, rack-debug19.

The install instructions aren’t up-to-date for Rails 3, so here’s my version.

# Gemfile
group :development do
  gem "ruby-debug19"
  gem "rack-debug19", :require => 'rack-debug'
end

# Rakefile
require 'rack-debug/tasks'

# development.rb
YourAppName::Application.configure do
  config.middleware.use 'Rack::Debug'
...
end

We specify a ‘:require’ in the gemfile b/c the gem name has changed, but the libs inside have the original name and bundler needs to require them as such.

Fire off ‘bundle install’, and things should go nicely, with 1.9.x-appropriate version of our debug libs and all their dependencies.

Advertisement

One Response to Using rack-debug with Ruby 1.9.2 and Rails 3

  1. Thanks for the post Rafi. Was a good help towards figuring out the current state of doing this with Rails.

    I think David’s most recently released a version 2.0 of rack debug.

    At this point all I had to do was

    gem ‘rack-debug’, ‘~> 2.0′

    and then add in the rake tasks and middleware bits, and voila!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s