Exercise 0

This assignment is about installing Ruby. Do this before your first lab to avoid flooding the local network. These directions assume you are using a Windows box such as your school computer; Mac and Linux users can ask your instructor for help if they need it, but Ruby is pretty easy to install on those systems.

  1. Visit rubyinstaller.org, click on the downloads button, and download the most recent, stable version of Ruby. For consistency, use the 32-bit version of Ruby (such as "Ruby 3.1.1 (x86)" as opposed to "Ruby 3.1.1 (x64)"). Use the version without DevKit. Having said that, using a slightly different version is unlikely to matter for any assignments we will do this term.
  2. Execute the installer. It will prompt you for a folder in which to install Ruby; feel free to change the default. I installed mine into d:\apps\Ruby31. In addition, put a check box in "Add Ruby executables to your PATH". You can also check "associate .rb and .rbw files with this Ruby installation", but be warned that this can mean executing Ruby files by mistake. I prefer to explicitly use the ruby command when running files.
  3. Open a command prompt (Start | All programs | Accessories | Command Prompt). Yes, we're going to use the command prompt from time to time in this course. IDEs can be useful, but they can also get in the way of getting simple things done. You can make life with command prompts in Windows much easier by doing the following:
    1. Right click on the command prompt icon in the start menu and select "Pin to Start".
    2. Click on the start button again, right click on the command prompt icon, and select Properties.
    3. In the Options tab (under Edit Options), enable QuickEdit Mode. You can then copy text by selecting it and pressing the Enter key or right clicking on the title bar and using the Edit menu.
    4. Click on the Colors tab. The default color is gray on black which most people have to squint to see. Pick a high-contrast color combination that works for you. I like bright green on black, but almost any color from the right half of the bar will work well. You can also pick dark on a light background, but be sure to change the pop-up text color and background as well.
    5. Click on the Font tab and pick a font size you can see easily. The chosen default was probably set up back when 600 by 800 pixels was the resolution you found on high end screens.
    6. Click on the Layout tab and change the height to a reasonable number like 30. You might also want to increase the screen buffer height.
    7. Click on the OK button.
  4. Enter the command
            ruby --version
    
    It should respond with the version you just installed. If it's a different version or you get a message saying it's not recognized as a command, you need to add Ruby to your execution path:
    1. Right click on the Start icon and select System.
    2. click on "Advanced system settings" in the left panel.
    3. Click on the Environment Variables... button.
    4. In the System variables section, scroll down and select "Path".
    5. Click on Edit...
    6. Click on the Add Directory button and browse to the folder containing the Ruby executable. It is probably something like C:\apps\ruby24\bin.
    7. Click on OK
    8. Open a new command prompt and retry printing the ruby version. If it does not work, you may have mistyped a character; edit your path until it works.
    This procedure is worth learning; you'll probably use it often after installing a command-line application. Windows searches the Path to find commands to be executed.
  5. Test out Ruby by typing
            irb
    
    This will start the Interactive Ruby environment.
  6. You should now be at a prompt of the form irb(main):001:0>. Enter
            puts 'Hello, world!'
    
    to write and execute your first Ruby program.
  7. Enter
            exit
    
    to return to the command prompt. Pressing Control-D will also leave.