Ruby is an open-source, high-level programming language known for its simplicity.
Whether you're building web applications, automating tasks, or just starting to learn to code, Ruby is a great language to begin with.
How Ruby Works
Ruby is an interpreted language, which means that the Ruby interpreter executes code line by line instead of compiling it first.
When you run a Ruby file, the Ruby interpreter reads the code and executes it immediately.
Running Ruby
There are two common ways to run Ruby:
- Run Ruby Online
- Run Ruby on Your Computer
In this tutorial, you will learn both ways of running Ruby.
Run Ruby Online
If you don't want to install anything, you can run Ruby code directly in your browser using an online interpreter.
We've built a fast, beginner-friendly online Ruby interpreter that lets you write, run, and test Ruby code instantly—no setup is needed.
If you're a beginner, we recommend using this learning approach.

Run Ruby on Your Computer
If you prefer to run Ruby locally on your computer, this guide will walk you through the steps for setting it up on Windows, macOS, or Linux (Ubuntu).
Install Ruby on Windows
To run Ruby locally on your Windows computer, follow these steps:
- Install Visual Studio Code
- Download and Install Ruby
- Verify Your Installation
Step 1: Install Visual Studio Code
First, you'll need a code editor. We recommend Visual Studio Code (VS Code) because it's lightweight, powerful, and beginner-friendly.
- Visit the VS Code official website
- Download the Windows installer.
- Once the download finishes, run the installer.
- Follow the setup instructions.
- Click Finish once the installation is complete.
Step 2: Download and Install Ruby
To run the Ruby code, you need to install the Ruby interpreter on your computer. Go to rubyinstaller.org and download the latest stable version of Ruby (with DevKit).

Open the .exe
installer you downloaded and follow the instructions. During installation, make sure to check the box that says " Add Ruby executables to your PATH".

The installation will begin, and you'll see a screen like this:

Once the installation is complete, you'll see a screen like this:

Click the Finish button to proceed to the final screen, as shown below:

Click the Enter button and proceed to the next step.
Step 3: Verify Your Installation
After installation, you can verify that Ruby is set up correctly. Open the command prompt and type the following command:
ruby -v
If everything is installed properly, you'll see something like:

This confirms that Ruby is installed and working on your system.
Install Ruby on MacOS
To run Ruby on your macOS computer, follow these steps:
- Install Visual Studio Code
- Check or Install Ruby
- Verify Your Installation
Step 1: Install Visual Studio Code
First, you need a good code editor to write Ruby programs. Visual Studio Code (VS Code) is highly recommended.
Go to the VS Code official website. Download the macOS installer. Open the downloaded .dmg
file and drag VS Code into your Applications folder.
Launch VS Code to start coding.
Step 2: Check or Install Ruby
macOS comes with Ruby pre-installed. You can check the version by opening Terminal and typing:
ruby -v
If you see a version number, Ruby is already installed. However, this version may be outdated.
To install the latest Ruby version, use Homebrew, a package manager for macOS. First, install Homebrew if you don't have it already. In Terminal, run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After Homebrew installs, install Ruby by running:
brew install ruby
Step 3: Verify Your Installation
Once Ruby is installed or confirmed, check the version to ensure it's set up correctly:
ruby -v
You should see the version of Ruby installed.
Install Ruby on Linux
To run Ruby on your Ubuntu Linux system, follow these steps:
- Install Visual Studio Code
- Install Ruby
- Verify Your Installation
Step 1: Install Visual Studio Code
To write Ruby programs, it's helpful to use a code editor like Visual Studio Code. Open your Terminal. Download and install VS Code by running these commands:
sudo apt update
sudo apt install software-properties-common apt-transport-https wget
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
sudo apt install code
Once installed, you can launch VS Code by typing code
in Terminal or from your applications menu.
Step 2: Install Ruby
Ruby is not installed by default on most Linux distributions. To install Ruby on Ubuntu, open Terminal and run:
sudo apt update
sudo apt install ruby-full
This installs the full Ruby environment.
Step 3: Verify Your Installation
After installation, check that Ruby is installed correctly by typing:
ruby -v
Run Your Ruby Code
Once Ruby is installed on your system, running your code is simple. Just follow these steps:
1. Open VS Code
First, open Visual Studio Code. Click on File in the top menu and then select New File.

2. Save the File
Next, save the file with a .rb
extension. Click on File, then Save As, and save the file as hello_world.rb
.
3. Write Your Code
Now, write the following code in your hello_world.rb
file:

4. Run the Ruby File
To run your Ruby code, open the VS Code terminal by selecting Terminal > New Terminal from the top menu. Then, run the following command:
ruby hello_world.rb

Now that you've set up everything to run Ruby programs on your computer, you'll learn how to work with basic Ruby features in the next tutorial.