Installing ruby-debug-ide19 on Ruby 1.9.3 (p125) from RailsInstaller 2.1.0

This has been quite a little journey. In the end, I’m happy with the solution though as it appears to be pretty elegant and, most importantly, seems to work at the moment. First, some background.

I’ve recently had a big interest develop in Ruby. Not necessarily so much for the language itself as for Rails. I can only go so long hearing so much good about something that I have to go and check it out for myself. Last week I read through Why’s Poignant Guide over a day and a half and feel pretty good with the language (even metaprogramming). So, the time came to get my IDE up and running. I chose Aptana Studio 3 since it’s Eclipse based and I like Eclipse. Their setup instructions include how to install a Ruby debugger for use within Eclipse.

I installed Ruby on Windows using RailsInstaller 2.1.0, the latest available at the moment, which installs Ruby 1.9.3 p125. Based on Aptana’s instructions, I knew I needed to install the ruby-debug-ide19 gem and so I entered their given command.

gem install ruby-debug-ide19

And I was greeted with a warm error message.

ruby_debug.c:29:19: error: conflicting types for
  ruby-1.9.3-p125/vm_core.h:505:7: note: previous
  declaration of 'rb_iseq_compile_with_option' was here

“How quaint,” I thought. “This is exactly what turns some people off to open source software.” Well, not wanting to be dissuaded I started looking for solutions. After searching for a while, I came up with my own. Alter the “ext/ruby_debug/extconf.rb” within the ruby-debug-base19-0.11.25.gem file (can be opened with 7-Zip). The alterations are to comment lines 19 and 21 (in red).

#if RUBY_REVISION >= 26959 # rb_iseq_compile_with_option was [...]

I could now proceed…only to be met with a second, more interesting error.

  undefined reference to `ruby_threadptr_data_type'

Wow, how interesting is that! This thing just doesn’t want to compile OR link! It’d been a while since I’d done this much work trying to get something to compile in C/C++, but I had a good background from the past. So this should be easy, right? Four days later, I think I have a solution.

Many people who encountered this started installing ruby-debug-base19x to get around it. Apparently this is a fork off ruby-debug-base19 which is maintained with one of the IDEs to try and fix some of the challenges ruby-debug is having with Ruby 1.9. That’s all fine and good, and it would install for me, but I needed a ruby-debug-ide19 to go along with it that Aptana could use. No such luck for me, so I was back to the drawing board.

I also found this post and tried to use the information there to resolve my problem. This just led me down a rabbit hole of trying to compile Ruby on Windows from source. I didn’t like where that was headed so I started looking into the libraries in my Ruby/lib directory. Sure enough, libmsvcrt-ruby191.dll.a didn’t include a ruby_threadptr_data_type export. However, libmsvcrt-ruby191-static.a did include it. Strange, but still not a solution.

Finally, I compared the sources for ruby_debug.c between ruby-debug-base19-0.11.25 and ruby-debug-base19x-0.11.30.pre10. I found that there was a new function definition in the 19x version.

static inline const rb_data_type_t *
  static const rb_data_type_t *thread_data_type;
    if (!thread_data_type) {
  VALUE current_thread = rb_thread_current();
  thread_data_type = RTYPEDDATA_TYPE(current_thread);
return thread_data_type;

#define ruby_threadptr_data_type *threadptr_data_type()

I’d already messed with the GEM file earlier, so why not again? I modified the ruby-debug-base19-0.11.25.gem file again, this time adding the above function to ruby_debug.c at line 195. I saved the GEM modifications and tried installing again. Voilá! MAGIC!

Until I tried to use the debugger in Aptana Studio (Eclipse).

Exception in DebugThread loop: undefined method `is_binary_data?'

Wow…this thing just didn’t want to work. Fortunately for me, someone else already had a great fix in this post on Stack Overflow. I edited my ruby-debug-ide19-0.4.12/lib/ruby-debug/xml_printer.rb file to include this definition (from the above article).

EDIT: To help others, I should clarify exactly where in the file this is done. I made the changes between the require statements at the beginning and the module Debugger line. In other words, this addition to the String class should occur outside the Debugger module.

class String
  def is_binary_data?
    ( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 ||
      self.index( "\x00" ) ) unless empty?

And now, peace. The wonderful peace brought by having a debugger running inside an IDE of your choice.

For those who don’t know exactly how I’m editing the GEM file, look in your gem cache, usually located in <Ruby install path>/lib/ruby/gems/<version #>/cache.

In case it matters, here’s the versions I’m running of everything I could think would affect this.

  • Ruby = 1.9.3 p125
  • Ruby Gems = 1.8.16
  • DevKit = 4.5.2
  • ruby-debug dependencies
    • columnize = 0.3.6
    • archive-tar-minitar = 0.5.2
    • linecache19 = 0.5.12
    • ruby_core_source = 0.1.5
  • ruby-debug-base19 = 0.11.25
  • ruby-debug-ide19 = 0.4.12

Hope this helps someone else beginning in their Ruby journey!

– Archimedes

This entry was posted in Geekery and tagged , , . Bookmark the permalink.

11 Responses to Installing ruby-debug-ide19 on Ruby 1.9.3 (p125) from RailsInstaller 2.1.0

  1. Nulike says:

    Great article! However, how do I edit gems in Windows? 7-Zip doesn’t offer a neat way to recompress the gems once the source has been edited…

    • Nulike,

      Thanks for reading! I edited the gems using 7-Zip in Windows so I hope I can help here. Open the .gem file using 7-Zip (the latest version should recognize it) and then navigate to the files that need editing. Drag-and-drop the file into some other location (i.e. your Desktop) and don’t close 7-Zip! Now edit the file using, say, Notepad++. Once the file is edited, drag-and-drop it back into the 7-Zip window. Now move “up” in the directory tree in 7-Zip until you are out of the .gem file. While navigating up, you should be asked to update the associated TAR and GEM files. If you get prompted, you know you’ve done something right!

      Please let post back if you get it to work or have any other questions!


      • Nulike says:

        Hello again. For some reason, I can’t get the last step to work properly… Do I include those lines inside module Debugger, or outside of it?

    • Nulike,

      No worries, thanks for posting back on your progress! The modification to xml_printer.rb should be made outside the Debugger module. Here’s how my file starts out after the alterations:

      ————- BEGIN xml_printer.rb —————–
      require ‘cgi’
      require ‘yaml’

      # added to resolve is_binary_data? removal after 1.9.1
      class String
      def is_binary_data?
      ( self.count( “^ -~”, “^\r\n” ).fdiv(self.size) > 0.3 || self.index( “\x00” ) ) unless empty?
      # end add

      module Debugger
      [… rest of file …]
      ————- END xml_printer.rb —————–

      Let us know if this works for you!


  2. Nulike says:


    For some reason I don’t think the debugger is reading the new xml_printer.rb file. I’ve edited the one located in C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\ruby-debug-ide19-0.4.12\lib\ruby-debug, is this path correct?

    Sorry for the inconvenience, I’m still new to Rails…

  3. Nulike says:

    Well, my stack trace differs slightly from yours, but I still think it’s the same issue. IdentitiesController is a controller where I put a breakpoint. Just as I try to trigger the breakpoint this happens:

    Exception in DebugThread loop: undefined method `is_binary_data?’ for “#”:String
    c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/xml_printer.rb:124:in `print_variable’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/xml_printer.rb:71:in `block in print_variables’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/xml_printer.rb:253:in `print_element’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/xml_printer.rb:69:in `print_variables’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/command.rb:85:in `method_missing’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/commands/variables.rb:130:in `execute’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:78:in `block (2 levels) in process_context_commands’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:71:in `each’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:71:in `block in process_context_commands’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:70:in `catch’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:70:in `process_context_commands’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:39:in `block in process_commands’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:35:in `catch’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug/processor.rb:35:in `process_commands’
    from: c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:140:in `block in start_control’

    • Nulike, sorry for the latency in my reply. I’ve been busy working some jobs and have had zero time to get back with you. I’m not sure what could be going wrong other than the code not coming through correctly in my post. Try downloading my xml_printer.rb file from the following location.

      Modified xml_printer.rb file, ZIPped.

      You’ve got the location correct on your local drive. Hopefully putting the file in place directly will do the trick.


  4. Osvaldo says:

    This is an excellent post that helped me in getting the debugger to work with Aptana 3 and Ruby 1.9.3 on Ubuntu.

    However, I have a question. I noticed you are using ruby-debug-ide19 (0.4.12), and currently I’m using ruby-debug-ide (0.4.16). If I uninstall this gem and install ruby-debug-ide19, Aptana doesn’t like it and gives me an error telling that ruby-debug-ide is not found, thus, the debugger doesn’t work.

    So, the question is, did you do anything on the side that let you to work with Aptana and ruby-debug-ide19, instead of ruby-debug-ide?

    • Osvaldo, thanks for the comment. I’ve been busy lately and haven’t had any time for this blog (very unfortunately). I don’t recall doing anything special to get Aptana 3 to use ruby-debug-ide19. In fact, it was the Aptana 3 documentation that led me to installing the “ide19” version rather than the “ide” one.

      Aptana Studio Ruby Debugger documentation

      From that site: “There are specific versions for Ruby 1.8 versus Ruby 1.9. To install for Ruby 1.9, be sure to install the ruby-debug-ide19 gem.” I’m wondering if Ubuntu’s Ruby gems are working differently than the Windows ones? That wouldn’t make a lot of sense, but it’s always possible.

      Let us know if you’ve figured out anything else related to this. I’m not above installing Ubuntu in a VM to try and replicate the issue to see if we can find a solution.


  5. Mick D says:

    Absolute Live saver – this worked perfectly for me on 1.9.3p125 with these gems, i edited using 7-Zip and TextPad.


    Nice work!

  6. Tiago says:

    Amazing, worked like a charm with:


    Thank you so much! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *