当前位置: 首页 > 知识库问答 >
问题:

OSX中的rubymine无法连接到rdebug-ide启动的会话

陶瀚玥
2023-03-14

表面问题是:rubymines可以运行ruby程序,但不能调试它们,也不能远程调试,我得到了:

>> DIALOG: Connecting to debugger using 10 seconds

大约10秒钟后

>> DIALOG: Cannot connect to the debugged process at port 57000 [a random port]
>>>         Dumping and destroying...
>>>         Error Output: 
>>>         Fast Debugger(ruby-debug-ide 0.4.17.beta14, ruby-debug-base19 0.11.30.pre10) listens on 127.0.0.1:57000
>> Please try increase timeout settings...(a long bullshit)

我尝试通过阅读ruby-debug-ide和ruby-debug-base 19代码来找到根本原因,发现:

  1. ruby debug ide已经启动了一个DebugThread(@control_thread),它将在127.0.0.1上启动TCPServer绑定,并在端口57000上侦听。
  2. ruby debug ide正在等待客户端连接到tcp服务器,并向其发送“start”命令到runprogscript
  3. 我可以<code>telnet 127.0.0.157000</code>,然后调试线程说:从127.0.0.1连接…如果我在telnet中输入一个单词“start”,rdebug ide将启动我的真正程序
  4. Rubymine没有连接到它并发送“启动”命令。(因为我在idea.log中没有找到任何输出)

我深入idea.log:

Fast Debugger (ruby-debug-ide 0.4.17.beta14, ruby-debug-base 0.11.30.pre10) listens on   127.0.0.1:59598
at org.rubyforge.debugcommons.RubyDebuggerProxy.a(RubyDebuggerProxy.java:647)
at org.rubyforge.debugcommons.RubyDebuggerProxy.d(RubyDebuggerProxy.java:619)
at org.rubyforge.debugcommons.RubyDebuggerProxy.getCommandSocket(RubyDebuggerProxy.java:381)
at org.rubyforge.debugcommons.RubyDebuggerProxy.b(RubyDebuggerProxy.java:151)
at org.rubyforge.debugcommons.RubyDebuggerProxy.attach(RubyDebuggerProxy.java:112)
at org.jetbrains.plugins.ruby.ruby.debugger.impl.RubyDebugProcess.attachToProxy(RubyDebugProcess.java:190)

然后,我阅读了调试公共代码(不像rubymine那么准确,我指的是https://github.com/ruby-debug/debug-commons-java/blob/master/src/org/rubyforge/debugcommons/RubyDebuggerProxy.java

private Socket attach() throws RubyDebuggerException {
  int port = debugTarget.getPort();
  String host = debugTarget.getHost();
  Socket socket = null;
  for (int tryCount = (timeout*2), i = 0; i < tryCount && socket == null; i++) {
    try {
          socket = new Socket(host, port);
          ...
    }
  }
}

似乎rubymine不能使用debug-commons库在localhost上打开套接字连接,我不能挖掘更多:(

顺便说一下,即使我们通过下面的命令在shell中启动ruby调试会话:

rdebug-ide --port 51202 -- path/to/my/script

rubymine也无法连接到插座。

*不要告诉我我应该使用另一个ruby-debug-xxx宝石或删除一些其他宝石,如ruby-debug,我已经尝试过这些解决方案。*

我尝试了以下组:

组 1:

  • 红宝石 4.0.3
  • 红宝石调试基地19-0.11.29
  • Ruby-debug-ide-0.4.16

第二组:

  • rubymine 4.5.x
  • ruby-debug-base19-0.11.30.pre10
  • ruby-debug-ide-0.4.17β14

我的笔记本电脑是OSX狮子的mac air

共有2个答案

施文彬
2023-03-14

我应该使用远程调试器而不是本地调试。

首先,比较本地调试错误:

Error:

  Cannot connect to the debugged process at port 57000 [a random port]

  Dumping and destroying...

  Error Output: 
  Fast Debugger(ruby-debug-ide 0.4.17.beta14, ruby-debug-base19 0.11.30.pre10) listens on 127.0.0.1:57000

  Please try increase timeout settings...(a long bullshit)

使用debug-conons-java'code:

private void failWithInfo(ConnectException e) throws RubyDebuggerException {
    String info = debugTarget.isRemote()
            ? "[Remote Process at " + debugTarget.getHost() + ':' + debugTarget.getPort() + "]"
            : Util.dumpAndDestroyProcess(debugTarget);
    throw new RubyDebuggerException("Cannot connect to the debugged process at port "
            + debugTarget.getPort() + " in " + timeout + "s:\n\n" + info, e);
}

我在上面的错误输出中看不到任何debugTarget.getHost(),但是如果我们远程调试,它会告诉我主机。

所以我写了一个最简单的ruby脚本(test.rb):

i = 10
begin
  puts "echo ok #{i}"
  i += 1
  sleep 1
end until i > 600

然后默认配置在Ruby my中启动远程调试会话:

    < li >远程主机:本地主机 < li >远程端口:1234 < li >远程根文件夹:path/to/test < li >本地端口:26201 < li >本地根文件夹:path/to/test

我发现红宝石显示异常为:

Error:

  Cannot connect to debugged process at port 54321 in 10s:

  [Remote Process at **localhost**:54321]

然后我把远程主机改成“127.0.0.1”,搞定!

所以我猜Rubymine会尝试使用“localhost”作为主机名来连接调试目标,但是失败了!

我尝试找到调试目标的主机初始化的位置,我在调试公地RubyDebuggerWorks中获得了这些代码:

private static RubyDebuggerProxy startDebugger(final Descriptor desc, final List<String> args, final int timeout)
        throws IOException, RubyDebuggerException {

   ...
    // 127.0.0.1 seemingly works with all systems and with IPv6 as well.
    // "localhost" and InetAddress.getLocalHost() have problems on some systems.
    // cf. http://www.netbeans.org/issues/show_bug.cgi?id=143273 for one case
    RubyDebugTarget target = new RubyDebugTarget(proxy, "127.0.0.1", desc.getPort(),
            pb.start(), desc.getDebuggeePath(), desc.getBaseDirectory());
    proxy.setDebugTarget(target);
    RubyDebuggerProxy.PROXIES.add(proxy);
    return proxy;
}

反编译rubymine.jarorg.rubyforge.debugcommons.RubyDebugger工厂,虽然它是混合的,但我们可以找到:

    RubyDebugTarget rubydebugtarget = new RubyDebugTarget(rubydebuggerproxy, "127.0.0.1", descriptor.getPort(), processbuilder.start(), descriptor.getDebuggeePath(), descriptor.getBaseDirectory());

我认为rubymine连接到127.0.0.1,但没有足够权限,所以我尝试通过以下命令启动ruby mine:

sudo /Applications/Rubymine.app/Content/MacOSX/rubymine

但它仍然失败了,所以这是rubymine的一个bug,如果你像我一样有这样糟糕的体验,请使用远程调试器来避免它。

感谢您提醒丹尼斯·乌沙科夫的计算机名称

时仰岳
2023-03-14

我有同样的问题。我尝试了所有建议(删除 ruby-debug、行缓存等),但没有一个有效。就我而言,我的Macbook的主机名设置为本地主机。我更改了我的主机名sudo scutil --set HostName newHostName,现在它运行良好。

 类似资料:
  • 我已经在mac上安装了jprofiler 9(安装了以前的版本,但首先使用附带的un安装程序卸载了它们)。但是,它无法启动-崩溃报告为: 崩溃的线程:0 AppKit线程调度队列:com。苹果主Thread 异常类型:EXC_BAD_ACCESS(SIGABRT)异常代码:KERN_INVALID_ADDRESS0x0000000030353230 0x30353230附近的VM区域:-- 特定于

  • 我已经将一个 Ruby 项目加载到 RubyMine 中,它的规范文件像往常一样位于目录中。右键单击并选择对任何单个等级库文件的“运行”可以正确运行它。右键单击并选择目录上的“全部运行”会导致每个测试失败并显示以下消息: 无法加载:/Users/Nathaniel/repos/close-web/spec/compositions/analysis/analysis _ data _ spec .

  • 我按照这个https://spring.io/guides/gs/accessing-data-mysql/指南连接mysql db到Spring启动项目 但是在运行应用程序时出现以下错误,我正在生成Spring starter项目,并且在通过Spring工具套件创建项目时仅选择web、mysql和jpa框 以下是application.properties 和pom.xml 编辑:添加sprin

  • 2)我使用的是自定义的,但现在我使用的是原来的: 3)Tomcat正确启动,我看到我的计算机中打开了端口8080。实际上,我必须手动关闭进程才能再次尝试从Netbeans运行新的程序,否则它会抱怨端口已经打开。与此同时,Netbeans只是等待,等待……在“等待Tomcat”之后的某个时候,它只是说它失败了,就像它不能识别Tomcat打开了一样。Tomcat保持运行,就像没有人与它通信一样。所以没

  • 我在Ubuntu WSL中使用vscode,它在几个小时前工作正常,当我开始写js时突然停止工作。 我尝试过删除和重新安装vscode,但这不起作用,并且出现错误:当我尝试清除时,出现无法找到包代码。 将vscode远程连接到wsl时,出现如下错误: 以下是来自 wsl 乌班图的调试报告:

  • 我刚刚配置了JBoss Wildfly。它正在运行,可以从同一台机器上访问,一切都很好... 我的问题是它不能从另一个系统访问(我的意思是在网络中,服务器(主机)URL不能从另一个系统访问)。 我该怎么解决这个?