RubyMine 2024.2 Help

IRB/Pry console

RubyMine allows you to run the IRB or Pry console and interact with your application without leaving the IDE. You can use completion and navigation capabilities, run the console with additional options, and so on.

IRB console completion

Before using the IRB/Pry console, make sure that the Ruby interpreter is configured for your project. To use Pry, make sure that the pry gem is installed for your interpreter.

Run a console

To run the IRB /Pry console in RubyMine, perform the steps below:

  • Do one of the following:

    • Press Ctrl twice and type the question mark in a popup. Then, find the irb or pry command in a list and press Enter. If necessary you can pass additional parameters, for example:

      irb -r ./script
    • Go to Tools | Run IRB or Tools | Run Pry.

RubyMine will load the IRB /Pry console with the selected project SDK.

IRB console

Note that a console can be launched on a remote SDK.

Run a console with additional options

After you run the console for the first time, RubyMine creates the dedicated run configuration. If necessary, you can change the created configuration to provide additional options: preload your code into IRB, add additional libraries or gems, and so on. For example, to load code from the script.rb project file into the IRB console, perform the steps below:

  1. Open the Run/Debug Configurations dialog in one of the following ways:

    • Press Ctrl+Shift+A, start typing Edit Configurations, select it from the list and press Enter.

    • Expand the run/debug configuration selector on the main toolbar and select Edit Configurations.

      Edit run configurations
  2. In the invoked Run/Debug Configurations dialog, select the created IRB console configuration in the Ruby Console group and specify the Console script arguments option in the following way:

    -r ./script

    Click OK.

Run source code from the editor in a console

RubyMine allows you to run source code from the editor in the IRB console. To do this, perform the following steps:

  1. Open the required Ruby file in the editor (if necessary, select a fragment of code to be executed).

  2. In the main menu, go to Tools | Load file/selection into IRB/Rails console.

Use a console

You can perform the following actions in a console:

  • Execute commands

    Type commands in the console and press Enter to execute them.

  • Multiline editing

    Type a line of code and press Shift+Enter to move the caret to the next line without executing a command.

  • Complete names

    Use basic code completion Ctrl+Space to complete names of classes, methods, and so on.

  • Navigate through history

    Use the Up and Down arrow keys to scroll through the history of commands and execute the required ones.

  • Navigate to source code

    To navigate to the initial declaration of a symbol and symbol's type, place the caret at the desired symbol and press Ctrl+B.

  • View quick documentation

    To get quick information for any symbol or method signature, place the caret at the desired symbol and press Ctrl+Q.

Last modified: 26 May 2024