我无法让我的 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

但是,当我运行此命令时,我收到以下消息:
ruby - 我怎样才能让 ruby​​-debug-ide 工作?-LMLPHP

我还尝试了上述命令的修改版本:(额外的破折号)
rdebug-ide --port 1236 --dispatcher-port 26166 --host 0.0.0.0 -- bin/rails s -b 0.0.0.0

结果我得到了这个:
ruby - 我怎样才能让 ruby​​-debug-ide 工作?-LMLPHP
这起初看起来不错,但随后服务器永远不会启动。它从不显示服务器信息,它只是停在这里并挂起,直到我按 CTRL+C 离开服务器。我无法让 rdebug-ide 与 Rails 一起工作。有谁知道我该如何解决这个问题?

最佳答案

我有 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 远程调试。

ruby - 我怎样才能让 ruby​​-debug-ide 工作?-LMLPHP

填写表单并单击调试按钮。服务器立即不再卡在那里,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 中设置断点,并开始远程调试 :-)

关于ruby - 我怎样才能让 ruby​​-debug-ide 工作?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32638976/

10-11 03:02
查看更多