Eclipse is one of the most popular programming IDEs available today. Very few development environments can stand against it in terms of features or ease of use. Except for editing very small/few number of files, for which the fast responsiveness of the simple editors might be more desirable, Eclipse is becoming the most preferred development environment. Its flexible plugin system has allowed the community to work towards enhancing/adding new functionality to the core product, just like it happened with emacs. The open source license and the plugin system has aslo meant that the IDE today supports most of the popular programming languages making Eclipse far more that just a Java IDE. One such language supported by Eclipse with the support of plugins is Ruby. If you are a Ruby/Rails developer, then you must definitely give Eclipse + Ruby plugin a try.

Download and Install Eclipse

Skip this section if you already have Eclipse installed on your system.

One way to install Eclipse would be to use the appropriate package manager for your distribution like apt, emerge, yum, yast etc. If you want the latest version though, downloading it separately and uncompressing it in the home directory would be an ideal way. In this case, follow these steps:

  1. Download Eclipse from here.
  2. Extract the downloaded file in the home directory(say /home/user).
  3. Make sure atleast the Java runtime(JRE) is installed(complete Java SDK is required to create Java programs from Eclipse) on the system. Go to the extracted directory and run the ‘eclipse’ executable file to check if everything is working properly.

Downloading and Installing Ruby plugin for Eclipse

Follow these steps:

  1. Download the Ruby plugin for Eclipse by selecting a mirror from here
  2. Extract the downloaded file in a temporary directory(say /home/user/temp).
  3. Copy the contents of the extracted directory in the corresponding Eclipse folders:
    /home/user/temp/features/* —-> /home/user/eclipse/features/
    /home/user/temp/plugins/* —-> /home/user/eclipse/plugins/

    (Use the path to the Eclipse installation folder if its not installed in the home directory).

  4. Confirm if the Ruby plugin is successfully installed by starting the eclipse IDE and going to Help->About Eclipse SDK->Plug-in Details.
  5. Scroll down the list of installed plugins to find the Ruby plugin.

Configure the Ruby plugin

Before being able to create Ruby programs from Eclipse, we need to provide it with the information regarding where Ruby is installed. If Ruby is not already installed, then install it first. Then follow these steps:

  1. Start Eclipse IDE and go to Window->Preferances->Ruby->Installed Interpreters->Add.
  2. Enter the following details:
    Interpreter Name: ruby
    Location: /usr/bin/ruby

    To find the location where ruby is installed on your machine, run the following command:

    sh# which ruby
    /usr/bin/ruby

  3. Now go to Window->Preferances->Ruby->Ri/rdoc and enter the following information:
    RDoc Path: /usr/bin/rdoc
    Ri Path: /usr/bin/ri

  4. Fill whatever location you have found out in the earlier step using `which` command.

Creating a Sample Ruby Application From Eclipse

  1. To create a Ruby application, create a Ruby project from File->New->Project
  2. Select Ruby->Ruby Project. Click ‘Next’, enter a project name and click ‘Finish’.
  3. Select File->New->Ruby Class to create a new class or select File->New->File to create a simple Ruby file. Type a program in the editor and save it.
  4. Now right-click on the file name and select Run As->Ruby Application to run the script.
  5. You can also debug the Ruby programs from within Eclipse. Click the ‘Debug’ button on the toolbar and select a Ruby script to start debugging it.

    The debugger is started and ready.

Other excellent development environments for Ruby application development include Komodo IDE, Emacs, Vim, SciTE etc. I will try to write about these development environments in the next few posts.