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
Get a terminal logged in to a GHC machine or unix.andrew.cmu.edu.
In the terminal, open the file .cshrc (Heed the dot!) with gedit by using the command:
gedit ~/.cshrc &The existing file should look something like this:
# Indirect pointer to the global .cshrc file. source /usr/local/lib/global.cshrc #
Add the following line to the bottom of .cshrc:
setenv RUBYLIB /afs/andrew.cmu.edu/usr22/vonronne/public/15110/rubylabs-15110/lib
Save the modified .cshrc and exit gedit.
Type the command:
cp -b /afs/andrew.cmu.edu/usr22/vonronne/public/15110/irbrc ~/.irbrc
Log out of the GHC/unix.andrew.cmu.edu system and then log back in.
Open a terminal with a command-line.
Ask Ruby to evaluate the expression Source (with a capital "S").
>> Source => RubyLabs::Source
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
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 line we added to .cshrc creates an "enviornment variable" called RUBYLIB which gets passed into the irb program and tells irb an extra place to look for Ruby programs. The file .irbrc contains Ruby commands that irb executes at startup. The cp command above copies a version that contains a command to automatically load the rubylabs module (from the place specified by the RUBYLIB enviornment variable).