< back to blog posts

Debugging Ruby 1.9


I finally decided it was time to start working with Ruby 1.9 on all new projects. It's flexibility with character encoding was to much of an advantage for this particular project. It was worth any problems that might come up.

I started by using RVM to make switching between various ruby version easy. The install process is described here. One gotcha is that I had a heck of a time with my gems. By aware that you may have to reinstall rubygems for each version of ruby. I had rubygems installed, but ruby couldn't find it. Use the 'which gems' and 'which ruby' commands to help track down this problem.

Once rvm was installed and I re-installed all my gems, it was time to start development. Most things went smoothly, but I was not happy to discover that ruby-debug no longer worked in ruby 1.9. After much hunting I found a fork of ruby-debug that was updated for ruby 1.9 at http://github.com/mark-moseley/ruby-debug.

The gem is installed with "gem install ruby-debug19"

You can then load the gem into your application with:

unless ENV["RAILS_ENV"]=="production"
   config.gem "ruby-debug19", :lib => "ruby-debug"
end

Your debugger commands will now work. It's back to requiring the 'eval' command instead of automatically executing code you type, but it gets the job done. I hope this helps!