How to connect a Ruby IDE debugger to a shell process?

I want to use the Ruby IDE debugger to debug a ruby โ€‹โ€‹process running in the shell, since it is spawned, for example. using the "rails console".

I got a great run from the debugger when starting a web server (from inside Rubymine) or test suites (also running from Rubymine).

However, if the process is not running Rubymine, I cannot attach the debugger.

I am using Rubymine 3.2.4 on Ubuntu with Sun Java 1.6.0_26, Ruby REE 1.8.7 and the latest debugging stones:

ruby-debug-base (0.10.4) ruby-debug-ide (0.4.17.beta8) 

Thoughts?

+7
source share
3 answers

Use the Ruby Remote Debug configuration type in RubyMine. See the official RubyMine documentation for more details.

You basically run the script like:

 rdebug-ide --port <port number> -- script.rb 

and then connect to the specified port from the RubyMine debugger.

+3
source

Here's how you do it in Rails:

First make sure you have rdebug-ide installed:

 gem install ruby-debug-ide --platform=ruby 

Then run this in the console:

 rdebug-ide --port 6778 -- /projects/your_rails_project/script/rails console 

or for rails 4.0 +

 rdebug-ide --port 6778 -- /projects/your_rails_project/bin/rails console 

Or, as @ChristopherWe mentioned below , you can pass the --host option if you want to debug a non-local server. (Read his comment below for reservations)

This will wait for remote debug clients to connect.

  • Click Run> Edit Configurations in RubyMine, then add an instance of Ruby Remote Debug.

  • Use the same port as above 6778 (If you change the above, make sure the ports match)

  • The root folder and the local root folder are the same, / projects / your _rails_project

  • Click "Apply and Close."

Then select this configuration from the list next to the start and debug buttons, then click the debug button. Give it a few seconds and the console will launch the rails console, wherever you run "rdebug-ide"

+5
source

I really want to post something here that is very difficult to find a complete answer for him, and it took me a lot of time to figure it out. There are people who ask how to connect a remote debugging process to find an employee, and here is the right way that works, finally, for me. This article is high on Google search and will be easy to find.

FROM SHELL on the server (for me it's my laptop), do this from your root site: rdebug-ide --port 1236 --dispatcher-port 26166 --host 0.0.0.0 bin / rake resque: work QUEUE = *

in the RubyMine IDE, remote debugging is configured using: Remote host: 127.0.0.1 Remote port: 1236 Remote root folder: path from the server to the root of the site Local port: 26166 Local root path: the path on your workstation to the root file where you must install breakpoints (in my case, all of it is local, so all 1 path and 1 copy of files)

Start the web server as usual: rails s

set a breakpoint in your Resque worker and try to do everything you need on your site to get to that breakpoint.

1 note - the presence of pearls "spring" gave me errors, and I had to comment on it / layering.

+2
source

All Articles