15110 FALL 2012 [Touretzky/Kaynar]

RubyLabs Setup Instructions

The author of the text book has created a library of modules called RubyLabs to support the tutorials and projects in the text book. These instructions describe how to enable the use of the RubyLabs modules for you andrew id user account. This will enable you to use the RubyLabs modules on the Gates Hall Cluster machines and when ssh'ing into unix.andrew.cmu.edu


  1. Get a terminal logged in to a GHC machine or unix.andrew.cmu.edu.

    1. If you are physically sitting at a Gates Hall Cluster machine, this can be accomplished by selecting the "Terminal" option from the "System Tools" submenu of the "Applications" menu at the upper-left corner of the desktop.
    2. If you are physically somwhere else, you may ssh (with X11 forwarding) into unix.andrew.cmu.edu.
  2. At the command prompt, in the terminal, enter the command:


    This will produce output similar to the following:

        Setting up your Andrew account for RubyLabs...
        Modifying /afs/andrew.cmu.edu/usrXX/andrewid/.cshrc
        Creating a /afs/andrew.cmu.edu/usrXX/andrewid/.irbrc file loads rubylabs
  3. Log out of the GHC/unix.andrew.cmu.edu system and, then, log back in.

How do I know if it worked?

  1. Open a terminal with a command-line.

  2. Run irb.

  3. Ask Ruby to evaluate the expression Source (with a capital "S").

    1. If RubyLabs is working, the result should look like:
      >> Source
      => RubyLabs::Source
    2. If RubyLabs is not working, the result will look something like:

      irb(main):001:0> Source
      NameError: uninitialized constant Source
      	from (irb):1
      	from :0

This will likely not work if you did not first log out and log back in after running ~vonronne/public/15110/bin/setup-rubylabs.sh.

What about graphics?

RubyLabs provides a Canvas object for graphical output. In addition, to irb needing to be able to find RubyLabs. RubyLabs will need to be able to find the X11 graphics subsystem. If you are at one of the machines in the Gates Hall Cluster, it should work. If you are accessing remotely, you will need to have X11 and ssh configured correctly (just like you do for running gedit remotely).

You can test the RubyLabs canvas by typing the following command in irb:


If everything is working correctly, a window with the title "RubyLabs::HelloWorld" will pop up.


Linux/UNIX allows file names to start with a dot, but these are considered special and are usually not displayed to the user. Many programs read from particular "dot files" in the user's home directory to configure themselves at startup. The ".cshrc" file is used by csh (which is the program that gives you the command line to type in your commands within the terminal); it contains a list of commands to be executed when the terminal is opened. The setup-rubylabs.sh program adds a line to .cshrc that creates an "enviornment variable" called RUBYLIB which gets passed into the irb program and tells irb an extra place to look for Ruby programs. It also creates a file .irbrc and makes a back up copy of any pre-existing file of that name. The file .irbrc contains commands that irb executes when it is started. The version it creates contains a command to automatically load the rubylabs module (from the place specified by the RUBYLIB enviornment variable).