Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » Debugging JRuby in Java container with dltk(How to debug JRuby scripts called from Java using a ScriptingContainer (RedBrdige) and dltk )
Debugging JRuby in Java container with dltk [message #692553] Mon, 04 July 2011 18:10 is currently offline
Messages: 1
Registered: July 2011
Junior Member

I'm trying to get interactive debugging working on my JRuby scripts that are called from Java.

My Java code goes basically like this:

System.setProperty("jruby.debug.fullTrace", "true");
ScriptingContainer container = new ScriptingContainer(LocalContextScope.CONCURRENT);
// ... setup of load path, gem directory and other extraneous stuff omitted here
container.runScriptlet("require 'my_ruby_stuff'");

And my_ruby_stuff.rb starts out like this:

require 'rubygems'
require 'ruby-debug'
require 'ruby-debug-ide'
Debugger.wait_connection = true

I have also inserted a debugger line into my Ruby script a little further along, at the point where I want debugging to start.

I can run my Java app from Eclipse, and debugging seems to start correctly in the embedded Ruby script. On the Eclipse console, I get the following messages:

Fast Debugger (ruby-debug-ide 0.4.16, ruby-debug-base listens on

...and the script apparently waits where I told it to. So an IDE debugger client should be able to attach to my script, right?

To try to do this, in Eclipse debug configurations, I created a new Remote Ruby Application configuration. Initially, Eclipse didn't let me register my Java project in the "Project" field, so I added <nature>org.eclipse.dltk.ruby.core.nature</nature> to the <natures> element in my project file. After that, I could add the project to the Remote Ruby Application debug config. I set the port, and a required Ide Key.

However, when I try to connect to my script with this debug config, it doesn't work--a connection is never established.

I also tried adapting the instructions at http: //, extracting the .rb source files from the plugin jars as suggested, and setting the mentioned environment variables as part of the run config of the calling Java app. However, including a

require 'FastRunner.rb'

in my Ruby script either raises an error or changes nothing (depending on what other libraries I require first).

However, I can connect to the embedded Ruby script using the command line debugger (and not using the require 'FastRunner.rb'). If in my Ruby code I do this:

require 'rubygems'
require 'ruby-debug'
# removed from setup: require 'ruby-debug-ide' 
Debugger.wait_connection = true

..then I can go into my Ruby code from the console with a simple rdebug --client -p 8989

(Strangely, the port number I have to use here is one less than the port number announced in the console message from ruby-debug-ide when I use that gem, as I mentionned above.)

Also, if I just say

require 'rubygems'
require 'ruby-debug'

then I get the command-line Ruby debugger inside an Eclipse console (which I guess, technically speaking, is debugging inside Eclipse, but it's not quite what I want...)

Any suggestions would be greatly appreciated.

BTW, I'm using JRuby 1.6.2 (though I had to bring it down to 1.5.6 to get ruby-debug-ide to make the native extensions for that gem to compile). ruby-debug version is 0.10.4, ruby-debug-ide version is 0.4.16, Eclipse 3.6.2, dltk 3.0 (though when I tried it with the require 'FastRunner.rb', I was using 2.0). On Debian GNU/Linux testing/unstable amd_64.

Many thanks in advance,
Previous Topic:Using SQL Indexer for Non-SourceModules
Next Topic:Implement C/C++ style #include the DLTK way...
Goto Forum:

Current Time: Tue Mar 05 11:25:02 GMT 2024

Powered by FUDForum. Page generated in 0.02020 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top