我有 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 中设置断点,并开始远程调试 :-)