Starting the Debugger Session
RubyMine allows you to run or debug entire Rails applications or specific Ruby scripts. The universal way to do this is using configured sets of startup parameters - run/debug configurations. For instance, you can specify the following parameters for the Rails run/debug configuration: a server type (such as Puma or Passenger), IP address and port, environment (development by default), and so on.
Run/debug configurations can be created in various ways, for example:
When you run a Ruby script or Rails server, RubyMine automatically creates a corresponding temporary configuration, which can be saved.
For Rails projects, RubyMine automatically creates the development and production run/debug configurations with the corresponding Rails environments.
For any project, you can create run/debug configurations manually from the predefined templates.
Learn more at Creating and Editing Run/Debug Configurations.
Before debugging
Set the breakpoints in the source code.
If necessary, create or modify the corresponding Run/Debug configuration.
Debug an application using a specific run/debug configuration
Use one of the following ways to debug a program with a specified Run/Debug configuration:
-
Press Ctrl twice to invoke the Run Anything popup. Start typing the required configuration name and select it from the list. Then, hold down the Shift key (the dialog title will be changed to Debug) and press Enter.
-
Click the button on the toolbar to run the currently selected run/debug configuration.
-
Select the
(Shift+F9) command from the main menu and select the required configuration.
Debug a Ruby script
To debug a specified ruby script (for example, script.rb), do one of the following:
-
Press Ctrl twice to invoke the Run Anything popup and type the ruby script.rb command. Then, hold down the Shift key (the dialog title will be changed to Debug) and press Enter.
-
Right-click a script in the editor or project tool window, and select Debug 'script'.
The actions above create the temporary run/debug configuration that can be changed and saved. You can also debug a Ruby script by creating a run/debug configuration manually and running this configuration as described in Run an application using a specific run/debug configuration.
Debug Rails applications
For Rails projects, RubyMine automatically creates the development and production run/debug configurations with corresponding Rails environments. For each configuration, you can specify a server type (such as Puma or Passenger), IP address and port, environment (development by default), and so on. The procedures below show how to change the Rails configuration and start debugging.
Change the Rails debug configuration
-
Press Ctrl+Shift+A and start typing Edit Configurations. Select Edit Configurations and press Enter.
-
In the invoked Run/Debug Configurations dialog, select the required configuration and specify its settings.
For example:
-
Server - Specifies a web server for running an application. You might need to install a corresponding gem to the project SDK (for example, the passenger gem for the Passenger server).
-
Environment - Allows you to select the Rails environment.
-
Run browser - Enables opening an application automatically in a default browser.
-
Debug the Rails application
-
Press Ctrl twice.
-
Start typing the required configuration name, select it from the list. Then, hold down the Shift key and press Enter.
-
(Optional) If the debase and ruby-debug-ide gems required for debugging have not been installed yet, RubyMine suggests installing them.
-
Wait until RubyMine starts the Rails server. The Debug tool window shows the application output.