Using debugger with jruby

I’m using jruby-1.6.6 in 1.9 mode and I want to use debugger in a
rails application.
I’m trying to install gem ruby-debug19 but I have the error:

Installing linecache19 (0.5.12) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /home/mauro/jruby/bin/jruby extconf.rb

WARNING: JRuby does not support native extensions or the `mkmf’
library very well.

How can I use debugger with jruby?

I believe ruby-debug works for JRuby, regardless of the language mode.


Hiro

On 12 February 2012 16:35, Hirotsugu A. [email protected] wrote:

I believe ruby-debug works for JRuby, regardless of the language mode.

I’m trying ruby-debug but in debug mode when I do, for example:

(rdb:2) break 10

I run into this error:

INTERNAL ERROR!!! undefined method entries' for #<String:0x531afc6a> /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/linecache-ruby.rb:8:in lnums_for_str’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/tracelines.rb:25:in
lnums_for_str_array' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/linecache.rb:282:in trace_line_numbers’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/breakpoints.rb:71:in
execute' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:226:in one_cmd’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:319:in
process_commands' org/jruby/RubyArray.java:1614:in each’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:318:in
process_commands' org/jruby/RubyKernel.java:1195:in catch’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:311:in
process_commands' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:199:in at_line’
(eval):5:in at_line' (eval):3:in at_line’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/ruby-debug-base.rb:55:in
at_line' /home/mauro/projects/operatorieconomici/app/controllers/application_controller.rb:4:in ApplicationController’
/home/mauro/projects/operatorieconomici/app/controllers/application_controller.rb:1:in
(root)' org/jruby/RubyKernel.java:1062:in load’
/home/mauro/projects/operatorieconomici/app/controllers/application_controller.rb:469:in
load_file' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:639:in new_constants_in’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:468:in
load_file' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:353:in require_or_load’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:502:in
load_missing_constant' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:192:in const_missing’
org/jruby/RubyArray.java:1614:in each' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:190:in const_missing’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in
const_missing' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/inherited_resources-1.3.0/app/controllers/inherited_resources/base.rb:11:in InheritedResources’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/inherited_resources-1.3.0/app/controllers/inherited_resources/base.rb:1:in
(root)' org/jruby/RubyKernel.java:1062:in load’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/inherited_resources-1.3.0/app/controllers/inherited_resources/base.rb:469:in
load_file' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:639:in new_constants_in’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:468:in
load_file' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:353:in require_or_load’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:502:in
load_missing_constant' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:192:in const_missing’
org/jruby/RubyArray.java:1614:in each' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:190:in const_missing’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in
const_missing' /home/mauro/projects/operatorieconomici/app/controllers/companies_controller.rb:2:in (root)’
org/jruby/RubyKernel.java:1062:in load' /home/mauro/projects/operatorieconomici/app/controllers/companies_controller.rb:469:in load_file’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:639:in
new_constants_in' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:468:in load_file’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:353:in
require_or_load' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:502:in load_missing_constant’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:192:in
const_missing' org/jruby/RubyArray.java:1614:in each’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:190:in
const_missing' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in const_missing’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:229:in
constantize' org/jruby/RubyArray.java:1614:in each’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:228:in
constantize' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:554:in get’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:62:in
controller_reference' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:47:in controller’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:26:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/journey-1.0.1/lib/journey/router.rb:68:in call’
org/jruby/RubyArray.java:1614:in each' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/journey-1.0.1/lib/journey/router.rb:56:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:589:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/sass-3.1.15/lib/sass/plugin/rack.rb:54:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/warden-1.1.0/lib/warden/manager.rb:35:in
call' org/jruby/RubyKernel.java:1195:in catch’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/warden-1.1.0/lib/warden/manager.rb:34:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/best_standards_support.rb:17:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/etag.rb:23:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/head.rb:14:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/remotipart-1.0.2/lib/remotipart/middleware.rb:30:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/params_parser.rb:21:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/flash.rb:242:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in
context' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/cookies.rb:338:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:64:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:408:in
_run__1733520973__call__515768123__callbacks' org/jruby/RubyBasicObject.java:1694:in send
org/jruby/RubyKernel.java:2095:in send' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in __run_callback’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:390:in
_run_call_callbacks' org/jruby/RubyBasicObject.java:1694:in send
org/jruby/RubyKernel.java:2095:in send' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in run_callbacks’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/reloader.rb:65:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/remote_ip.rb:31:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:16:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/show_exceptions.rb:56:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/railties-3.2.1/lib/rails/rack/logger.rb:26:in call_app’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/railties-3.2.1/lib/rails/rack/logger.rb:16:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/request_id.rb:22:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/runtime.rb:17:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/activesupport-3.2.1/lib/active_support/cache/strategy/local_cache.rb:72:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/lock.rb:15:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/static.rb:53:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/railties-3.2.1/lib/rails/engine.rb:479:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/railties-3.2.1/lib/rails/application.rb:220:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/content_length.rb:14:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/railties-3.2.1/lib/rails/rack/debugger.rb:20:in
call' /home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/railties-3.2.1/lib/rails/rack/log_tailer.rb:14:in call’
/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in
`service’

So is it a jruby bug?

You might wanna try pry, GitHub - pry/pry: A runtime developer console and IRB alternative with powerful introspection capabilities., it works for me on
1.9
mode running on 1.6.6

  • Samer

This is still an issue with the latest version. Are we going to have a
fully functional ruby-debug in JRuby anytime soon?

Msan M. wrote in post #1046179:

On 12 February 2012 16:35, Hirotsugu A. [email protected] wrote:

I believe ruby-debug works for JRuby, regardless of the language mode.

I’m trying ruby-debug but in debug mode when I do, for example:

(rdb:2) break 10

I run into this error:

INTERNAL ERROR!!! undefined method `entries’ for #String:0x531afc6a

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/linecache-ruby.rb:8:in

`lnums_for_str’

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/tracelines.rb:25:in

`lnums_for_str_array’

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.4-java/lib/linecache.rb:282:in

`trace_line_numbers’

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/breakpoints.rb:71:in

`execute’

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:226:in

`one_cmd’

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:319:in

process_commands' org/jruby/RubyArray.java:1614:in each’

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:318:in

process_commands' org/jruby/RubyKernel.java:1195:in catch’

/home/mauro/jruby-1.6.6/lib/ruby/gems/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/processor.rb:311:in

`process_commands’
[SNIP]

So is it a jruby bug?

I had the same issue, appears to be a bug in ruby-debug-base-0.10.4. I
thought maybe 0.10.5.rc1 with its new linecache dependency might fix it
but not, the issue remains. I’ve attached a patch that fixes the issue
on ruby-debug-base-0.10.4. The same patch can be applied to
linecache-0.46-java/lib/linecache/trace_nums.rb as well, it is a simple
two word change.