📚 Scripting Languages Tutorial

Scripting Languages

Learn scripting languages (Ruby, Perl, TCL and Tk) with simple explanations, examples, techniques and practical notes.

← Back to Scripting Languages

Installing Ruby

Before learning Ruby programming, we must install the Ruby interpreter and verify that it is working correctly.

Installing Ruby on Windows

To install Ruby on your Windows, just follow these steps:

  1. Download RubyInstaller
  2. Run the installer
  3. Install MSYS2 development tools
  4. Verify Ruby installation

Step 1: Download RubyInstaller

RubyInstaller official website

  • Click Download.
  • Download the recommended Ruby+Devkit version for Windows (Ex: Ruby+Devkit 4.0.9-1 (x64)).

Step 2: Run the installer

  • Open the downloaded .exe file (Ex: rubyinstaller-devkit-4.0.9-1-x64.exe).
  • Accept the license agreement.

Accept the license agreement

  • Select the installation directory (Ex: C:\Ruby40-x64) and enable the option “Add Ruby executables to your PATH”.

Select the installation directory and add Ruby to PATH

  • Click Install and select the required components.

Select the required components

Installation in progress

  • Click on Finish.

Step 3: Install MSYS2 development tools

After installation, the RubyInstaller setup may open a command prompt for MSYS2 installation.

  • Select the recommended MSYS2 installation option.
  • Allow the installation to complete.
  • Install the MSYS2 development toolchain when prompted.

These tools are useful for compiling native Ruby gems.

MSYS2 installation in the command prompt

Step 4: Verify Ruby installation

Open the Command Prompt and execute the following command.

ruby -v
Expected output:

Output of ruby -v on Windows

Installation of Ruby in Windows is successfully completed.

Installing Ruby on Linux (Ubuntu)

In Ubuntu Linux, Ruby can be installed using the APT package manager. To install Ruby on your Linux (Ubuntu), just follow these steps:

Step 1: Open the terminal

Press Ctrl + Alt + T to open the terminal.

Step 2: Update the package information

Execute the following command to update the package information from Ubuntu repositories.

sudo apt update

Output of sudo apt update

Step 3: Install Ruby

Execute the following command to install Ruby and the standard Ruby components.

sudo apt install ruby-full

If prompted, type Y and press Enter.

Output of sudo apt install ruby-full

Step 4: Verify Ruby installation

Execute the following command to verify the Ruby installation.

ruby -v

If the installation was successful, this command displays the version of Ruby like below.

Output of ruby -v on Ubuntu