Software Installation
To work on the tutorial projects in Explorations in Computing you need to install three different software packages:
- The Ruby programming language.
- A library called Tk, which is used to draw images on the screen in projects that include interactive visualizations.
- A set of modules known as RubyLabs, which contain the software used in the tutorial projects.
Each installation is a straightforward matter of downloading a single software package and using the default configuration parameters.
Ruby is a programming language that is widely used by web page developers and other software professionals. It is open source software, and can be freely downloaded and installed on any computer.
Note: Make sure you install Ruby version 1.8.7 and not Ruby 1.9 (see the note at left for more information).
The easiest way to install Ruby on Microsoft Windows is to use a pre-packaged installer from http://www.rubyinstaller.org.
The main page shows the most recent versions of Ruby, but you should install an older version.
Click on the "Download" link at the top of the page go to another page that lists several different alternatives.
Select the installer for Ruby 1.8.7 (as of April 2013 this version is named Ruby 1.8.7-p371).
When the installer starts it will show two options, asking whether you want Ruby to be added to your path and whether you want the installer to create icons.
Select both of these options, and then continue the installation, using the default settings.
Note: These instructions assume you know how to use a terminal emulator. If you have never used the Terminal application in Linux, refer to the Lab Manual to learn how to start and use Terminal.
To install Ruby on Ubuntu or similar systems, make sure your system is connected to the Internet, and then start the Terminal application and type this command:
sudo apt-get install ruby irb ri gem
You will be asked to type your password (when you type your password on a Linux command line it looks like nothing is happening, but just continue typing your password and hit the return key). After you hit the return key the system will begin the installation.
The apt-get command will install the Ruby language and three command line applications: irb, which is the Interactive Ruby interpreter; ri, a "help" program for getting information about Ruby; and gem, the Ruby package manager (which is used to install the lab software).
Note: Leave your terminal window open because you will be using it to install the remaining pieces of software, too.
If you are running Mac OS X 10.5 or later Ruby is already installed on your system and you can proceed to the next step.
If you have Mac OS X 10.4 or earlier download one of the "one click installers" from http://rubyosx.rubyforge.org.
Locate the installer for your version of the operating system and click on the yellow text that says "Download Ruby One-Click Installer" right above the name of the system.
After the installer has been downloaded, double-click on the package icon and follow the instructions, using all the default options.
Tcl/Tk is a software package that is widely used for creating windows, buttons, and other parts of graphical user interfaces. The RubyLabs modules use Tcl/Tk for projects that display graphics on the screen during an experiment. The version of Tcl and Tk we use comes from an organization called ActiveState.
To install Tcl/Tk on Microsoft Windows download the installer from ActiveTcl Downloads.
When the installer starts it will ask whether you want Tcl to be added to your path; tell it "yes" (which is the default option) and continue. Use the default choices for all the remaining questions, also.
Download the installer from ActiveTcl Downloads. Use the process you normally use to unpack the archive (e.g. on Ubuntu double click on the file to start the Archive Manager).
When the archive has been expanded you will have a folder with a name that starts with something like ActiveTcl8.5... In your terminal window, use the cd command to navigate to this folder, and type the following command:
sudo ./install.sh
You might be prompted for your password again. As the installation proceeds, whenever you are asked to enter some information, just hit the return key to use the default values that are displayed by the installer.
Download the installer from ActiveTcl Downloads. Double-click on the disk image icon to open a folder where you should see a package named ActiveTcl-8.5.pkg. Double-click on this package to start the installation process. When prompted, choose the default settings whenever you are asked to select an option.
Ruby programs that developers want to share with other programmers are typically distributed as "Ruby gems". The RubyLabs modules are installed by an application that connects to a "gem server" to download the RubyLabs gem.
Note: These instructions assume you know how to use the Command Prompt application, the terminal emulator that comes with Microsoft Windows. If you have never used Command Prompt, refer to the Lab Manual to learn how to start and use this program.
Start Command Prompt and type the following command to install the RubyLabs gem:
gem install rubylabs -n .
Make sure you type the command exactly as it's shown, with a space and a period at the end of the line.
It may not look like anything is happening at first, but be patient, the gem program is connecting to the gem server to find the RubyLabs modules. When the program finishes, type this command to run a script that completes the installation:
ruby lab-setup.rb
You're now ready for the final step. Continue with the instructions in the next section, which show you how to test the newly installed software.
Type the following command in your terminal emulator to make sure Ruby's package manager is up to date:
sudo gem update --system
After you hit the return key the gem program will check for updates. It may look like nothing is happening but be patient and eventually you will see a message saying the update is complete.
Next type this command to install the RubyLabs software:
gem install --user-install rubylabs -n .
Make sure you type the command exactly as it's shown, with two dashes before the word "user" and a space and a period at the end of the line (it might be a good idea to just copy and paste that command from your web browser into the terminal window).
Again it will look like nothing is happening, but the gem program is connecting to the gem server to find the RubyLabs modules. When the program finishes, type this command to run a script that completes the installation:
ruby lab-setup.rb
You're now ready for the final step. Continue with the instructions in the next section, which show you how to test the newly installed software.
Note: These instructions assume you know how to use a terminal emulator. If you have never used the Terminal application in Mac OS X, refer to the Lab Manual to learn how to start and use Terminal.
Start the Terminal application. Type the following command, which will make sure Ruby's package manager is up to date:
sudo gem update --system
You will be prompted to type your password. It will look like nothing is happening when you type (i.e. the password is not echoed on the terminal) but just type your full password and hit the return key. After you hit the return key the gem program will check for updates. It may look like nothing is happening but be patient and eventually you will see a message saying the update is complete.
Next type this command to install the RubyLabs software:
gem install --user-install rubylabs -n .
Make sure you type the command exactly as it's shown, with two dashes before the word "user" and a space and a period at the end of the line (it might be a good idea to just copy and paste that command from your web browser into the terminal window).
Again it will look like nothing is happening, but the gem program is connecting to the gem server to find the RubyLabs modules. When the program finishes, type this command to run a script that completes the installation:
ruby lab-setup.rb
You're now ready for the final step. Continue with the instructions in the next section, which show you how to test the newly installed software.
The method for making sure all the software has been downloaded and installed properly is the same for all systems.
Start your terminal emulator and type the following command to start an interactive Ruby session:
irb
When Ruby starts the prompt should change to a double greater-than sign (>>). Type hello and hit the return key.
If everything was installed correctly two things will happen: RubyLabs will print a friendly greeting in the terminal window, and it will create a graphics window with another "hello" message.
The instructions shown above for installing Ruby, Tk, and the RubyLabs gem are explained in more detail in the Lab Manual. The Lab Manual also has describes some of the things that can go wrong during the installation process and offers some suggestions for how to fix problems.