# Using the Interactive Ruby Shell to troubleshoot gems

> Use the Interactive Ruby Shell (irb) over SSH to test gem loading and debug Ruby environment problems.

Source: https://helpcenter.ruachost.com/developers/programming-languages/using-the-interactive-ruby-shell-to-troubleshoot-gems/

**Using the Interactive Ruby Shell to troubleshoot gems**\
Learn how to use the Interactive Ruby Shell to troubleshoot Ruby gem loading and configuration.

**The Interactive Ruby Shell (irb)** enables you to run Ruby commands directly from the terminal. It is useful for testing gem loading, checking environment settings, and debugging Ruby behavior.

**Basic Interactive Ruby Shell (irb) usage**\
To start irb, log in to your account using SSH and type:

```bash
irb
```

To debug a specific Ruby program:

```bash
irb program.rb
```

The default prompt appears like this:

```bash
irb(main):001:0
```

From the prompt, you can run any Ruby statement and see the output immediately. For example, to view the value of the **$0** global variable:

```bash
p $0
```

To exit irb:

```bash
exit
```

**Troubleshooting gems**\
You can use irb to confirm that your Ruby environment is correctly set up for loading gems.

1. Start irb:

```bash
irb
```

2. At the irb prompt, type the following commands. Replace **gem_name** with the gem you want to test:

```bash
require 'rubygems'
require 'gem_name'
```

For Ruby 1.8, rubygems must be required before any other gem.

You will get one of these results:

```
=> true
```

This means Ruby successfully loaded the gem.

**LoadError: no such file to load -- gem_name**\
This means Ruby cannot find or load the gem.

If you receive a LoadError, check the Ruby load path:

```bash
p $LOAD_PATH
```

The **$LOAD_PATH** array contains all directories Ruby checks when loading gems. If your gem directory is missing, configure the **GEM_HOME** and **GEM_PATH** environment variables so Ruby can locate the gems.

For step-by-step instructions on configuring Ruby gems on a ruachost.com account, please see the appropriate guide.

**More information**\
For additional details about the Interactive Ruby Shell, visit the official Ruby documentation website.
