Hi, I'm Samuel Cochran

on Twitter, Facebook, Google, LinkedIn, GitHub, Stack Overflow, and Steam.

Using ruby-debug on Ruby 1.9.3 preview1

UPDATE: confirmed still problematic on ruby 1.9.3 rc1. This fix still works. (Thanks @janminarik!)

Ruby 1.9.3 preview1 has a slightly broken build process. In the final step of compilation it hides a number of symbols while linking the ruby binary. This means ruby-debug's extension can't get all the information it needs to make the debugger work and it breaks.

To fix, first grab some coffee, tenderlove-style.

You need to recompile after removing a line from configure.in. Make sure you've got a copy of the ruby 1.9.3 preview1 source then apply this patch:

$ git apply <( curl [https://github.com/ruby/ruby/pull/47.diff](https://github.com/ruby/ruby/pull/47.diff) )


$ autoconf && ./configure --prefix="$HOME/.rbenv/versions/1.9.3-preview1" && make -j3

Double check it's worked by checking the _ruby_current_thread symbol is visible (or you can just trust me):

$ nm ruby | grep current_thread
00000001002249d0 D _ruby_current_thread

Then install as normal (make install), set up rubygems, gem install ruby-debug19 and try it out:

$ ruby -v -r rubygems -r ruby-debug -e 'Debugger.start and puts Debugger.current_context'
ruby 1.9.3dev (2011-07-31 revision 32780) [x86_64-darwin11.0.1]

Hooray! The future is now; you can get back to debugging your Rails 3.1 apps with ruby-debug on Ruby 1.9.3.

This probably isn't the canonical solution—I'm no autotools or C expert—but it works for now. I'm sure they'll fix it properly for the next release.