Installing Ruby

Dear Computer

Howtos

Installing Ruby

To run Ruby code, you need access to a Ruby interpreter. You can get access in a couple of ways: by installing it on your local machine, or by logging in to a departmental server. Having Ruby on your own computer has advantages: you're not relying on an internet connection, files can be manipulated using your operating system's file explorer, and you can update the interpreter or install packages. But installing it on your own system can sometimes be a nightmare of permissions issues and slow compilation of the Ruby platform. Choose a method for getting Ruby that works for you.

Stu

Ruby 3.2.3 in already installed on stu. Log in with your favorite SSH client or SSH-powered editor, and run a Ruby script from the command line like this:

ruby path/to/my/script.rb

For your spreadsheet project, you will need to import the Curses gem. This is also already installed.

macOS and Linux

If you are running macOS or Linux, you likely already have Ruby installed. But it may not be a very new version. Additionally, the builtin package management tools often don't correctly set permissions for non-administrator users. For these reasons, you are encouraged to use a Ruby version manager like rvm to install a separate Ruby. Rvm installs Ruby in your home directory rather than in system folders, so you won't encounter permissions issues.

Follow the version manager's instructions to install it and a recent version of Ruby. These commands install recent and stable versions of RVM and Ruby:

\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm install 3.2.3

Test that you can run a simple Ruby script. Then install the Curses gem with this command:

gem install curses

Windows

If you are running Windows, install Ruby using a stable version of RubyInstaller. Choose an option with the Devkit, which provides tools needed for compiling the Curses gem. Reload your editor after installing, and test that you can run a simple Ruby script. Then install the Curses gem with this command:

gem install curses

Some Curses features (like mouse events and cursor keys) may not work inside Visual Studio Code's terminal. Try using a separate terminal program like Powershell.

Trial Run

Test that your setup works by running this script:

require 'curses'

Curses.init_screen
Curses.addstr('press a key')
Curses.getch
Curses.close_screen
← Curses RecipesInstalling Haskell →