How can I get ruby-debug-ide to work?

假装没事ソ 提交于 2019-12-03 09:55:55

I've got RubyMine remote debugging to work :-)

Before you start, be sure you have debase and rdebug-ide installed:

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

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

1. Start Rails server

First of all, you need to start the Rails server:

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

For your reference, my Ruby, Rails and Ubuntu versions are:

$ 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

As you noticed, the server seems never starting. It just hangs there. This is actually correct. It hangs there, waiting to be connected, from RubyMine for example.

2. Remote debug from RubyMine

Now start RubyMine (I'm using RubyMine 2017.2.4), Run -> Debug... -> Edit Configurations...

Click plus sign '+' to add new configuration, and choose Ruby remote debug.

Fill the form and click the Debug button. Immediately the server does no longer hang there, and the Rails server gets started:

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

Finally, you can set breakpoints in RubyMine, and start remote debugging :-)

I believe you should add the command to the Ruby Remote Debug Configuration inside of RubyMine.

Run > Edit Configurations > Add Ruby remote debug configuration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!