Skip to content

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:

Terminal window
irb

To debug a specific Ruby program:

Terminal window
irb program.rb

The default prompt appears like this:

Terminal window
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:

Terminal window
p $0

To exit irb:

Terminal window
exit

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

  1. Start irb:
Terminal window
irb
  1. At the irb prompt, type the following commands. Replace gem_name with the gem you want to test:
Terminal window
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:

Terminal window
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.