Friday, December 21, 2007

Solution To The Rails Bug Which Utility Belt Exposes

...identified, on Rails core, by Mislav Marohnić:

I found out where .irbrc is included. Stable Rails apps have breakpoint_server set to "true" in dev mode. Well, that option makes "breakpoint.rb" get included in the dispatcher, which in turn requires IRB. Commenting out breakpoint_server in environments/development.rb fixes everything.

(Mislav found this when he installed Dr. Nic's map_by_method and encountered similar explosions.)

Update: Jeremy Kemper told me on ruby-talk that this is only an issue with old versions of Rails:

Rails 2 switched to ruby-debug since ruby-breakpoint broke when Binding.of_caller went the way of the dodo

He also objected to my calling this a bug in Rails. I think loading arbitrary .irbrc code into a non-IRB app probably really is a bug, and I can compromise and call it a pitfall instead, but if it does indeed trace back to breakpoint_server, which appears to be the case, then it's a non-issue anyway for the current version of Rails.

Long story short, it's easy to avoid the conflict by commenting out breakpoint_server if you don't use it, and it should never even happen with Rails 2.0 or higher.