RubyMine 2018.2 Help

Attaching to Remote Process

RubyMine enables you to attach to a running process on a local or remote computer. This capability allows you to debug applications that cannot be launched directly from the IDE.

In this topic, we’ll use this capability to debug the sample application for the Ruby on Rails Tutorial, which runs on a remote machine.

Prerequisites

In this tutorial, we’ll use two machines to demonstrate debugging of a remote application:

  • Local machine - Mac with macOS, with RubyMine installed.
  • Remote machine - The Ubuntu machine with enabled SSH access and the Ruby interpreter installed. In our tutorial, the remote computer has the following IP address: 172.20.210.41.

On both machines, we’ll use the jetbrains user’s home directories to store source code.

Clone and run a remote application

First of all, we need to clone and run the sample application on a remote machine. To do this, connect to a remote machine and use instructions from the Getting started section. After performing the required steps, use the rails server command to run an application:

rm remote attach mac console

Note that we’ll attach a debugger to the puma server later using the allocated process identifier (2758 on the screen).

Clone a project on a local machine

After running the sample application on a remote machine, launch RubyMine and open the same application on a local machine using this instruction: Opening Your Project for the First Time. In URL, insert the following address: https://bitbucket.org/railstutorial/sample_app_4th_ed.git. Then click Clone.

opening projects vc clone repository

Configure a remote interpreter

In this part, we’ll configure a remote interpreter using SSH. Open the Settings/Preferences dialog (Ctrl+Alt+S), go to the Language & Frameworks | Ruby SDK and Gems page, click the icons general add svg button and select New remote… in the drop-down:

rm remote attach new remote

In the invoked dialog, select SSH Credentials and specify parameters in the following way:

rm remote attach ssh credentials
  • Host - The IP address of a remote machine. In our tutorial, the IP address is 172.20.210.41, and the Port is set to the default value.
  • User name - The username used to authenticate on a remote machine.
  • Authentication type - In this field, select the Password value to authenticate a user with a password.
  • Ruby or version manager path - Here you should specify the path to the Ruby interpreter or the version manager executable. In this tutorial, we use RVM on a remote machine.

After you have specified all the settings, click OK. If you specified a path to the version manager executable in the previous dialog, RubyMine suggests you to select the Ruby interpreter used to run a remote application.

rm remote attach select distribution

Click OK and select the added SDK in the Ruby SDK and Gems page.

rm remote attach select remote sdk

The final thing you need to do is to specify mappings between files of a local and remote project. To do this, click the Edit Path Mappings icons vcs mapBase button. In the Edit Project Path Mappings dialog, specify the local and remote project root paths.

rm remote attach path mappings

In our case, the paths will look as follows:

Local Path - /Users/jetbrains/RubymineProjects/sample_app_4th_ed

Remote Path - /home/jetbrains/apps/sample_app_reference

Click OK in this dialog and then click OK in the Settings/Preferences dialog. Now we are ready to attach to a remote process and debug the application.

Attach to a remote process

Now we are ready to debug a remote application. Open the users_controller.rb file and set a breakpoint in the create method next to the flash method:

rm remote attach set breakpoint

Then, click Run in the main menu and select the Attach to Process… command. In the invoked dialog, select the remote connection in the SSH group (172.20.210.41@22 in our case) and choose the puma process with the identifier allocated during the web server launching (see Clone a project on a local machine):

rm remote attach process

The Console tab will display the debugger output:

rm remote attach debugger console

Debug an application

To debug an application, open the browser on a local machine and specify the application address. In our case, it will be http://172.20.210.41:3000.

rm remote attach browser signup

Click the Sign up now! button. On the Sign up page, enter the required user parameters and click Create my account.

rm remote attach browser parameters

The debugger pauses its session on a breakpoint and enables you to examine the remote application state.

rm remote attach debugger

For instance, you can check user parameters specified on the Sign up page.

Last modified: 6 August 2018