7

这听起来像是一个相当微不足道的问题,但我多年来一直在努力解决这个问题,放弃了 Ruby 并重新开始使用它。我是一名尝试学习 Ruby 的 Java/Eclipse 人员,因此我想在我的 Win 7 64 位计算机上使用一些Eclipse 插件调试 jRuby/Rails。怎么这么难?我找不到分步说明(例如安装此插件、此版本的 jRuby、安装这些 gem、调整这些设置)。如果没有那个,我就在碰碰运气,而我所做的一切似乎都会导致奇怪的错误。

此时,我正在尝试使用 EasyEclipse(这是一个不错的选择吗?)。我发现默认安装(到程序文件中)不是一个好主意,并将其安装在没有空格的路径上;与 jRuby 相同。我安装了两个调试 gem(从头顶开始,gem install ruby​​-debuggem install ruby​​-debug-ide),然后做了“gem update”。我正在运行 EasyEclipse 和 jRuby 的最新稳定版本。

我能够运行 Ruby 程序。但是,当我设置断点并尝试调试时,调试器卡在“Launching(95%)”并且控制台显示:

ruby 1.9.3 调试器在端口 52188 上侦听 Thread:Class 的未定义方法 `critical='

那,当我在首选项中打开“使用 ruby​​ 调试库”库时,我得到了这个:

   Fast Debugger (ruby-debug-ide 0.4.18, ruby-debug-base 0.10.3.2) listens on 127.0.0.1:52819
Hello, world!
Hello, world!2
Hello, world!3
Context.java:407:in `contextCopyLocals': java.lang.NoSuchMethodError: org.jruby.runtime.DynamicScope.getEvalScope()Lorg/jruby/runtime/DynamicScope;
    from Context.java:284:in `frame_locals'
    from Context$INVOKER$i$1$0$frame_locals_DBG.gen:-1:in `call'
    from JavaMethod.java:347:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:139:in `call'
    from CachingCallSite.java:306:in `cacheAndCall'
    from CachingCallSite.java:136:in `call'
    from CallNoArgNode.java:60:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from IfNode.java:118:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from IfNode.java:116:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:112:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:206:in `evalBlockBody'
    from Interpreted19Block.java:157:in `yield'
    from Block.java:142:in `yield'
    from RubyArray.java:1610:in `eachCommon'
    from RubyArray.java:1617:in `each'
    from RubyArray$INVOKER$i$0$0$each_DBG.gen:-1:in `call'
    from CachingCallSite.java:143:in `callBlock'
    from CachingCallSite.java:154:in `callIter'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from ASTInterpreter.java:112:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:206:in `evalBlockBody'
    from Interpreted19Block.java:157:in `yield'
    from Block.java:142:in `yield'
    from RubyContinuation.java:107:in `enter'
    from RubyKernel.java:1261:in `rbCatch19Common'
    from RubyKernel.java:1254:in `rbCatch19'
    from RubyKernel$INVOKER$s$rbCatch19_DBG.gen:-1:in `call'
    from CachingCallSite.java:177:in `callBlock'
    from CachingCallSite.java:188:in `callIter'
    from FCallOneArgBlockNode.java:34:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from WhileNode.java:131:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from RescueNode.java:222:in `executeBody'
    from RescueNode.java:117:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:139:in `call'
    from CachingCallSite.java:306:in `cacheAndCall'
    from CachingCallSite.java:136:in `call'
    from CallNoArgNode.java:60:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:268:in `call'
    from CachingCallSite.java:366:in `cacheAndCall'
    from CachingCallSite.java:238:in `call'
    from FCallThreeArgNode.java:40:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:268:in `call'
    from CachingCallSite.java:366:in `cacheAndCall'
    from CachingCallSite.java:238:in `call'
    from CallThreeArgNode.java:61:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:112:in `call'
    from InterpretedMethod.java:126:in `call'
    from RubyClass.java:722:in `finvoke'
    from Helpers.java:486:in `invoke'
    from RubyBasicObject.java:367:in `callMethod'
    from DebugEventHook.java:566:in `callAtLine'
    from DebugEventHook.java:553:in `callAtLine'
    from DebugEventHook.java:190:in `processEvent'
    from DebugEventHook.java:97:in `eventHandler'
    from EventHook.java:30:in `event'
    from Ruby.java:2882:in `callEventHooks'
    from ASTInterpreter.java:239:in `callTraceFunction'
    from NewlineNode.java:101:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:103:in `INTERPRET_CLASS'
    from ASTInterpreter.java:280:in `evalClassDefinitionBody'
    from ClassNode.java:138:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from RootNode.java:129:in `interpret'
    from ASTInterpreter.java:121:in `INTERPRET_ROOT'
    from Ruby.java:834:in `runInterpreter'
    from Ruby.java:2674:in `loadFile'
    from ExternalScript.java:66:in `load'
    from LoadService.java:359:in `load'
    from Debugger.java:137:in `load'
    from RubyDebugger.java:207:in `debug_load'
    from RubyDebugger$INVOKER$s$0$2$debug_load_DBG.gen:-1:in `call'
    from DynamicMethod.java:225:in `call'
    from DynamicMethod.java:221:in `call'
    from CachingCallSite.java:366:in `cacheAndCall'
    from CachingCallSite.java:238:in `call'
    from FCallThreeArgNode.java:40:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:182:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from RootNode.java:129:in `interpret'
    from ASTInterpreter.java:121:in `INTERPRET_ROOT'
    from Ruby.java:834:in `runInterpreter'
    from Ruby.java:2674:in `loadFile'
    from ExternalScript.java:66:in `load'
    from LoadService.java:359:in `load'
    from RubyKernel.java:1081:in `loadCommon'
    from RubyKernel.java:1073:in `load19'
    from RubyKernel$INVOKER$s$0$1$load19_DBG.gen:-1:in `call'
    from DynamicMethod.java:209:in `call'
    from DynamicMethod.java:205:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from FCallOneArgNode.java:36:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from RootNode.java:129:in `interpret'
    from ASTInterpreter.java:121:in `INTERPRET_ROOT'
    from Ruby.java:834:in `runInterpreter'
    from Ruby.java:842:in `runInterpreter'
    from Ruby.java:673:in `runNormally'
    from Ruby.java:518:in `runFromMain'
    from Main.java:390:in `doRunFromMain'
    from Main.java:279:in `internalRun'
    from Main.java:221:in `run'
    from Main.java:201:in `main'

这是怎么回事?

我想我可以继续在谷歌上搜索并尝试在黑暗中找到自己的方式,但我已经花了很多时间去做这件事,而且肯定有人在我之前完成了在 Eclipse 中调试 jRuby 的琐碎任务?帮助!

4

1 回答 1

2

下载 Eclipse 动态语言工具包 - Ruby 开发工具。导入您的 ruby​​ on rails 项目。检查您的 Gemfile 是否引用:

gem 'ruby-debug'

然后转到 windows -> 首选项,并做两件事:

  • 将 eclipse ruby​​ 解释器设置为:c:\jruby\bin\jruby.bat

JRuby日食

  • 设置 eclipse ruby​​ 调试引擎,因此它不是“快速调试器”而是“ruby 内置调试​​器”

在此处输入图像描述

然后在运行配置的主选项卡中,在“ruby 脚本”下的启动脚本是bin/rails,在参数选项卡server --debugger中。解释器选项卡应该指向 JRuby.bat

运行 -> 运行,并给它大约 30 秒的时间来加载 JVM、ruby 环境,然后将所有内容挂接到其中。然后检查你的http://localhost:3000/

要开始调试执行,请输入要启动调试debugger器的位置。

这一切开始看起来像这样:

Eclipse Ruby 调试器

于 2013-09-25T14:17:07.653 回答