4

我无法让我的 ruby​​-debug-ide 正常工作。我有一个基本的 Rails 应用程序,我想在 RubyMine 中进行调试。在我启动 RubyMine 之前,我需要在我的 vagrant VM 中启用 rdebug-ide。当我导航到我的项目目录时,我已经在线阅读我需要输入以下命令:

rdebug-ide --port 1236 --dispatcher-port 26166 --host 0.0.0.0 - bin/rails s -b 0.0.0.0

但是,当我运行此命令时,我收到以下消息: 在此处输入图像描述

我还尝试了上述命令的修改版本:(一个额外的破折号)

rdebug-ide --port 1236 --dispatcher-port 26166 --host 0.0.0.0 -- bin/rails s -b 0.0.0.0

结果我得到了这个: 在此处输入图像描述 起初看起来不错,但是服务器永远不会启动。它从不显示服务器信息,它只是坐在这里并挂起,直到我 CTRL+C 退出服务器。我无法让 rdebug-ide 与 rails 一起工作。有谁知道我该如何解决这个问题?

4

4 回答 4

4

我有 RubyMine 远程调试工作:-)

在开始之前,请确保您已安装 debase 和 rdebug-ide:

gem list | grep debase    
gem list | grep ruby-debug-ide

sudo gem install debase
sudo gem install ruby-debug-ide

1.启动Rails服务器

首先,您需要启动 Rails 服务器:

hello_rails$ rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- bin/rails server
Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.2.beta10, file filtering is supported) listens on 0.0.0.0:1234

供您参考,我的 Ruby、Rails 和 Ubuntu 版本是:

$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux-gnu]

$ rails -v
Rails 5.1.4

$ lsb_release -a
Description:    Ubuntu 16.04.3 LTS
Codename:       xenial

正如您所注意到的,服务器似乎永远不会启动。它只是挂在那里。这实际上是正确的。它挂在那里,等待连接,例如来自 RubyMine。

2. RubyMine 远程调试

现在启动 RubyMine(我使用的是 RubyMine 2017.2.4),运行 -> 调试... -> 编辑配置...

单击加号“+”添加新配置,然后选择 Ruby 远程调试。

在此处输入图像描述

填写表格并单击调试按钮。服务器立即不再挂在那里,Rails 服务器启动:

hello_rails$ rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- bin/rails server
Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.2.beta10, file filtering is supported) listens on 0.0.0.0:1234
WARN: Unresolved specs during Gem::Specification.reset:
      rake (>= 0.8.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
=> Booting Puma
=> Rails 5.1.4 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.10.0 (ruby 2.4.2-p198), codename: Russell's Teapot
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000

最后,您可以在 RubyMine 中设置断点,并开始远程调试 :-)

于 2017-10-24T22:12:09.013 回答
2

在更新版本的 ruby​​-debug-ide 中,您可以在运行时 --skip_wait_for_start 并且它会立即启动 rails 服务器(参见https://github.com/ruby-debug/ruby-debug-ide/pull/167/文件

于 2020-07-16T17:25:11.047 回答
0

我相信您应该将该命令添加到 RubyMine 内的 Ruby 远程调试配置中。

Run > Edit Configurations > Add Ruby remote debug配置。

于 2016-06-24T12:57:48.877 回答
0

在我的情况下,我必须-- bin/rails用相对路径替换:-- ../../../../../usr/local/bin/rails,因为一旦我按下CTRL+c我就看到了消息说明/usr/src/app/bin/rails没有找到。

于 2020-04-08T19:41:48.927 回答