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.
- 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.
- 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.
- 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:
- Right click on the command prompt icon in the start menu and select
"Pin to Start".
- Click on the start button again, right click on the command prompt
icon, and select Properties.
- 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.
- 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.
- 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.
- 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.
- Click on the OK button.
- 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:
- Right click on the Start icon and select System.
- click on "Advanced system settings" in the left panel.
- Click on the Environment Variables... button.
- In the System variables section, scroll down and select "Path".
- Click on Edit...
- Click on the Add Directory button and browse to the folder
containing the Ruby executable. It is probably
something like C:\apps\ruby24\bin.
- Click on OK
- 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.
- Test out Ruby by typing
irb
This will start the Interactive Ruby environment.
- 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.
- Enter
exit
to return to the command prompt. Pressing Control-D will also
leave.