RubyMine 7.1.2 Help

Remote Debugging

In this section:


RubyMine provides the possibility of remote debugging for Ruby and Rails applications, using the dedicated Ruby remote debug configuration. So doing, RubyMine keeps mapping between the local sources, and the sources on the server side.

Several debug processes can be launched simultaneously. So doing, each remote debug process starts in a separate tab in the Debug tool window, with the name Remote debug for <script name>. You can work with each debugging session as usual.

The common format of the command is as follows:

rdebug-ide --host --port <port number> --dispatcher-port <port number> -- $COMMAND$

You can see this command as a tip in the Ruby remote run/debug configuration dialog.

General steps

To debug an application remotely, follow these general steps

  1. Start remote debug session.
  2. Create local copy of the script to be debugged, and then set the required breakpoints.
  3. Create or edit Ruby remote debug configuration.
  4. Launch the debug server. To do that, type the following command on the server side:
    rdebug-ide --host <host_name> --port <local port number> --dispatcher-port <remote port number> $COMMAND$
    and then press Enter.

    Here <local port number> is local port on the remote host, <remote port number> - is the port on the local machine, where you want to debug, and $COMMAND$ is the name of the script or application to be debugged.

    For example, to remotely debug a Rails application, run the following command on the remote host:

    rdebug-ide --port 1234 --dispatcher-port 26162 –host – bin/rails s -b

    Also make sure that the gem ruby-debug-ide is bundled to the project.

  5. In RubyMine, select the desired Ruby remote debug configuration, open Ruby script in the editor, and click debug on the main toolbar.

Starting remote debug session

To launch the remote debug session, follow these steps

  1. On the main menu, choose Tools | Start SSH session.
  2. Choose Edit Credentials, and specify port number, user name and password, and then click OK:

    The remote connection starts in the dedicated tab of the local terminal.

  3. In the terminal, type the command starting the remote debug session, for example:
    rdebug-ide --host --port 1234 --dispatcher-port 26162 -/home/user/RubymineProjects/remote-debug-example/math_wiz.rb

    Here port is the port number on the remote host.
    dispatcher-port is the port number on the local host.

Creating a local copy of a script

In order to open our script in RubyMine to set breakpoints and finally start debugging, we need to copy it to the local host. The fastest way is to switch to the local tab of the Terminal tool window and copy the script to be debugged, for example:

#create a local folder mkdir ~/RubymineProjects/remote-debug-example #copy file to the local folder scp user@remote-host:RubymineProjects/remote-debug-example/math_wiz.rb ~/RubymineProjects/remote-debug-example/

Then open the folder with the copied script in RubyMine. RubyMine creates a new project, and prompts you to configure an interpreter for it.

Setting breakpoints

In the newly created project, open the script in question for editing and set the breakpoints as required.

Configuring run/debug configuration for remote debugging

To configure run/debug configuration for remote debug, follow these steps

  1. On the main menu, choose Run | Edit Configuration.
  2. In the Run/Debug Configurations dialog box, click add and choose Ruby remote debug configuration. The configuration of the selected type named unnamed is created.
  3. Specify the configuration name, for example, 'Remote debug configuration'.
  4. Specify the parameters of this configuration:
    • The name of the remote host
    • The number of the remote port, which should be the same as was used on starting the remote debug session.
    • In the Remote root folder specify the remote path to the script, e.g. /home/user/RubymineProjects/remote-debug-example/.
    • Local port should be the same as the port 'dispatcher'.
    • Local root folder should be the folder where the copied script is located on the local host, for example, /Users/jetbrains/RubymineProjects/remote-debug-example. This folder is the same as the one that contains the copied script.
  5. Apply changes and save this configuration.

Now we are ready to connect to the remote session and debug the script.

Running remote run/debug configuration in the debug mode

Run 'Remote debug configuration' in the debug mode, which is the only available mode. Local debugger connects to the remote session and stops on the breakpoint that was set locally in our script.

See the detailed instructions in the tutorial.

See Also

Last modified: 26 May 2015