OSX中的rubymine可以';无法连接到rdebug ide启动的会话

OSX中的rubymine可以';无法连接到rdebug ide启动的会话,ruby,macos,debugging,rubymine,Ruby,Macos,Debugging,Rubymine,表面上的问题是:rubymine可以运行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... >

表面上的问题是:rubymine可以运行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-base19代码找到根本原因,发现:

  • ruby debug ide已启动一个DebugThread(@control_thread),它将在127.0.0.1上启动一个TCPServer绑定,并在端口57000上侦听
  • ruby debug ide正在等待客户端连接到tcp服务器,并向其发送“启动”命令以
    run\u prog\u script
  • 我可以
    telnet 127.0.0.1 57000
    ,然后调试线程说:从127.0.0.1连接。。。 如果我在telnet中输入一个单词“start\n”,rdebug ide将启动我的实际程序
  • 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那么准确)

    private Socket attach()抛出RubyDebuggerException{
    int-port=debugTarget.getPort();
    字符串host=debugTarget.getHost();
    套接字=空;
    对于(int-tryCount=(timeout*2),i=0;i
    rubymine似乎无法使用debug commons库在localhost上打开套接字连接,我无法挖掘更多:(

    顺便说一句,我们甚至可以通过下面的命令在shell中启动ruby调试会话:

    rdebug ide--端口51202--路径/到/我的/脚本

    rubymine也无法连接到插座

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

    我试过以下几组:

    第一组:

    • 红霉素4.0.3
    • ruby-debug-base19-0.11.29
    • ruby-debug-ide-0.4.16
    第2组:

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

    我的笔记本电脑是带有OSX Lion的mac air

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

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

    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-commons-java的代码:

    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):

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

    • 远程主机:本地主机
    • 远程端口:1234
    • 远程根文件夹:路径/到/测试
    • 本地端口:26201
    • 本地根文件夹:路径/到/测试
    我发现rubymine显示异常为:

    Error:
    
      Cannot connect to debugged process at port 54321 in 10s:
    
      [Remote Process at **localhost**:54321]
    
    然后我将远程主机更改为“127.0.0.1”,完成

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

    我试图找到调试目标主机的初始化位置,我在debug commons RubyDebuggerFactory中获得了这些代码:

    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可以连接到127.0.0.1,但没有足够的许可,所以我尝试通过以下命令启动ruby mine:

    sudo/Applications/Rubymine.app/Contents/MacOSX/Rubymine

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


    感谢您在

    中提醒我计算机名,我也遇到了同样的问题。我尝试了所有建议(删除ruby调试、行缓存等)在我的例子中,我的macbook的主机名被设置为localhost。我更改了我的主机名
    sudo scutil--set hostname newHostName
    ,现在它工作得很好。

    防火墙阻止连接?在RubyMine中配置代理?试着看看
    tcpdump
    /
    wireshark
    会发生什么。你有计算机名规范吗ified in System Preferences | Share?我有一个计算机名为“air”,但无法删除。我的结论是:当我启动本地脚本的调试器时,Rubymine将debugTarget设置为“localhost”,这会覆盖debug commons硬代码中的“127.0.0.1”。
    Error:
    
      Cannot connect to debugged process at port 54321 in 10s:
    
      [Remote Process at **localhost**:54321]
    
    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;
    }
    
        RubyDebugTarget rubydebugtarget = new RubyDebugTarget(rubydebuggerproxy, "127.0.0.1", descriptor.getPort(), processbuilder.start(), descriptor.getDebuggeePath(), descriptor.getBaseDirectory());