# Debug in IRB/Rails console

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/ruby/2026.3/llms.txt).

After you have run the [IRB](running-console.html) or [Rails](running-rails-console.html) console, RubyMine creates a temporary [run/debug configuration](run-debug-configuration.html). This configuration allows you to rerun the console or launch it in the debug mode. In this topic, we'll show you how to load and debug specific parts of code in the IRB console.

A sample Ruby application used in this topic has two files: `script.rb` and `song.rb`. We'll debug the to_s method called for the newly created Song object. Use the code snippets below to create the files for the procedure.

script.rb:

```RUBY
require './song'
puts Song.new("My Way", "Sinatra").to_s
```

song.rb:

```RUBY
class Song
    def initialize(name, artist)
        @name = name
        @artist = artist
    end
    def to_s
        "Song: #{@name}--#{@artist}"
    end
end
```

Perform the following steps to debug this program code in the IRB console.

Procedure: Debug in IRB/Rails console

1. Open the `song.rb` file and set a breakpoint within the to_s method as follows.

![Set breakpoint](https://resources.jetbrains.com/help/img/idea/2026.3/rm_irb_debug_set_breakpoint.png)

2. Run the IRB console configuration in the debug mode. To do this, select this configuration on the main toolbar and click the ![Debug](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.startDebugger.svg) button.

![Debug IRB console](https://resources.jetbrains.com/help/img/idea/2026.3/rm_irb_debug_start.png)

3. In the opened `song.rb` file, place the caret at any line and select `Tools | Load File/Selection into IRB/Rails Console` from the main menu. This will load code from the file to the IRB console.

4. Open the `script.rb` file and select the to_s method call as follows.

![Select code](https://resources.jetbrains.com/help/img/idea/2026.3/rm_irb_debug_select_code.png)

Then, select `Tools | Load File/Selection into IRB/Rails Console` from the main menu. RubyMine loads this selection to the IRB console and stops program execution at the breakpoint.

![Debugger](https://resources.jetbrains.com/help/img/idea/2026.3/rm_irb_debug_stop_breakpoint.png)

In the invoked Debug tool window, you can investigate the application state: frames, variable values, and so on. Learn more at [Examine suspended program](examining-suspended-program.html).

## See also

### Procedures

[Debug](debugging-code.html) [Breakpoints](using-breakpoints.html)

