How can I get ruby-debug-ide to work?
Asked Answered
F

4

4

I can't get my ruby-debug-ide to work properly. I have a basic rails app, and I would like to debug in RubyMine. Before I even start RubyMine, I need to enable rdebug-ide in my vagrant VM. When I navigate to my project directory, I have read online I need to enter the following command:

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

However when I run this command, I get this message: enter image description here

I have also tried a modified version of the above command: (an extra dash)

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

And I get this as a result: enter image description here This looks good at first, but then the server never starts. It never displays the server info and it just sits here and hangs until I CTRL+C out of the server. I can't get the rdebug-ide to work in conjunction with rails. Does anyone know how I can fix this?

Filly answered 17/9, 2015 at 20:0 Comment(1)
are you using fixed IP from your vagrant configuration ? if not make sure to forward port you're using (1236) so the host can listen on this portBobbette
M
5

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.

enter image description here

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

Massotherapy answered 24/10, 2017 at 22:12 Comment(3)
I've been searching for this for hours. I don't have it working quite yet but I'm on the right track now. Ubuntu 16.x / Aptana StudioFrontality
Thank you for this, you helped me isolate a longstanding bug in RubyMine where only one Docker container can be debugged at a time (the issue is that we can only override the default ports 1234:1234 and 26166:26168 under the "Ruby remote debug" custom configuration, but not under the "Rails" custom configuration.). See: intellij-support.jetbrains.com/hc/en-us/community/posts/…Choragus
I'm attempting to get this working on a linux WSL 2 subsystem. It currently hangs in the IDE. So Im attempting to run it without the IDE When you run rdebug-ide bin/start etc command on its own. Should the app start? i.e. can you do a basic curl http://localhost:3000Brittnybritton
I
2

In more recent versions of ruby-debug-ide, you can --skip_wait_for_start when running and it will immediately start the rails server (see https://github.com/ruby-debug/ruby-debug-ide/pull/167/files)

Imminence answered 16/7, 2020 at 17:25 Comment(0)
F
0

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

Run > Edit Configurations > Add Ruby remote debug configuration.

Fungiform answered 24/6, 2016 at 12:57 Comment(0)
N
0

in my case I had to replace -- bin/rails with relative path: -- ../../../../../usr/local/bin/rails, because once I pressed CTRL+c I saw the message stating /usr/src/app/bin/rails was not found.

Nietzsche answered 8/4, 2020 at 19:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.