Aptana 3 ruby debugger - Exception in DebugThread loop: undefined method `is_binary_data?'
Asked Answered
N

3

6

I'm trying to debug simple ruby file in Aptana 3.

class HelloWorld
  
def initialize()
    
end
  
def greet()
  puts "hello world"
end
end

h=HelloWorld.new
h.greet

breakpoint is set to

h.greet

after I started debug, debugger starts, but when it tries to initialize ruby class, debugger disconnect with message

Fast Debugger (ruby-debug-ide 0.4.9) listens on :54749
Exception in DebugThread loop: undefined method `is_binary_data?' for "#<HelloWorld:0x85915fc>":String  

when I set breakpoint to

h=HelloWorld.new

debugger starts, but after I stepped into initialize() constructor, it disconnects with previous message

My gems list:

*** LOCAL GEMS ***

archive-tar-minitar (0.5.2)
bigdecimal (1.1.0)
columnize (0.3.6)
io-console (0.3)
json (1.5.4)
linecache19 (0.5.13)
minitest (2.5.1)
rake (0.9.2.2)
rdoc (3.9.4)
ruby-debug-base19 (0.11.26)
ruby-debug-ide19 (0.4.12)
ruby-debug19 (0.11.6)
ruby_core_source (0.1.5)

I have successfully applied these instructions, to solve problems with debugging but I still got this exception message

Any answer is welcome which shed a light to this problem.

Thank you.

Necessitous answered 22/1, 2012 at 13:21 Comment(0)
N
16

My ruby version:

ruby 1.9.3p0 (2011-10-30) [i386-mingw32]

My gems list:

...
linecache19 (0.5.13)
ruby-debug-base19 (0.11.26)
ruby-debug-ide19 (0.4.12)
...

In Aptana 3, I got same error.

Exception in DebugThread loop: undefined method `is_binary_data?' for "#<PostsController:0x65a8da8>":String

See ruby-debug-ide19-0.4.12 / xml_printer.rb .

  value_str = "[Binary Data]" if value_str.is_binary_data?
  print("<variable name=\"%s\" kind=\"%s\" value=\"%s\" type=\"%s\" hasChildren=\"%s\" objectId=\"%#+x\"/>",
      CGI.escapeHTML(name), kind, CGI.escapeHTML(value_str), value.class,
      has_children, value.respond_to?(:object_id) ? value.object_id : value.id)

See http://apidock.com/ruby/String/is_binary_data%3F .

String#is_binary_data?

This method is deprecated or moved on the latest stable version. The last existing version (v1_9_1_378) is shown here.

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

Add this code to xml_printer.rb (or to your code).

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

Thank you.

Nolie answered 28/1, 2012 at 6:35 Comment(3)
I have added this code, but still get Exception in DebugThread loop: undefined method `is_binary_data?' for #<String:0x22efb10>.Wira
+1 I couldn't understand why ruby 1.8.7 debug worked while ruby 1.9.3 didn't. Tried reinstalling the debugger gems, but that didn't work. Your solution worked perfectly.Fakir
I added the String class snippet to my environment.rb and all is working.Tarah
S
2

It worked for me, make sure the code is added outside of the "module Debugger" block in xml_printer.rb. I added the code inside the module block the first time and got the same exception, but placing it outside the module block got rid of the exception and allows variables to be inspected.

Starks answered 27/2, 2012 at 17:51 Comment(0)
B
2

I was using exabug's solution for a while but this awful bug in such a critical feature of a programming language like debugging didn't let me rest, so I investigated it a little bit closer, and that's what I found out.

Firstly, ruby-debug-ide implemented a workaround to the problem, which should be included in beta versions of the gem so you may give them a try. See here to find out what versions are available. The latest beta crashed on my computer, though, and I haven't tested the rest.

Secondly, the problem exists because is_binary_data? method has been moved to a standard library called Syck. So adding require 'syck' to xml_printer.rb is in my opinion a cleaner solution than both the one implemented by ruby-debug-ide and proposed by exabugs.

I'm quite new to Ruby but I must say a bug which completely prevents me from debugging anything, which remains unfixed in stable versions for a year, doesn't make a very good impression about the whole language.

Brilliance answered 3/12, 2012 at 21:38 Comment(1)
Your solution on adding require 'syck' to xml_printer.rb work WELL! thanks, i agree with yuo, i have spent half a day to make debugging running in NetBeans, thats owfull, i wish they do a better easy way of debugging setup & runDionne

© 2022 - 2024 — McMap. All rights reserved.