Install Ruby
Install Ruby

How to Install Ruby on Windows, macOS, and Linux – A Complete Guide 2025

Installing Ruby on Your Operating System

Install Ruby where Ruby, known for its simplicity and productivity, is widely used for web development, especially with the Ruby on Rails framework. In this guide, we’ll walk you through how to install Ruby on Windows, macOS, and Linux, so you can start coding in Ruby with ease.

Whether you’re a beginner or an experienced developer, this installation guide will cover everything you need to get Ruby up and running on your computer.


Why Install Ruby?

Installing Ruby opens up a world of development possibilities. Ruby is perfect for building web applications, automating scripts, and exploring object-oriented programming concepts. Its clear syntax and active community make it a great choice for both hobbyists and professional developers.


Installing Ruby on Windows

Method 1: Installing Ruby Using the RubyInstaller

  1. Download RubyInstaller:
    • Go to the official RubyInstaller website: RubyInstaller for Windows.
    • Download the latest recommended version of the RubyInstaller, which includes the MSYS2 development environment.
  2. Run the Installer:
    • Double-click the downloaded file and follow the installation instructions.
    • Make sure to check the box that says “Run ‘ridk install’ to setup MSYS2” at the end of the installation.
  3. Setting Up MSYS2 and Development Tools:
    • After the installation, a command prompt will open to install MSYS2 and development tools.
    • Choose the default options by pressing “Enter” for each prompt to complete the setup.
  4. Verify the Installation:
    • Open a new command prompt window.
    • Type ruby -v and press Enter. You should see the version of Ruby you installed.

Method 2: Using Windows Subsystem for Linux (WSL)

For those comfortable with Linux, another option is to install Ruby via the Windows Subsystem for Linux:

  1. Enable WSL:
    • Go to “Control Panel > Programs > Turn Windows features on or off”.
    • Check “Windows Subsystem for Linux” and restart your computer.
  2. Install a Linux Distribution:
    • Open the Microsoft Store, install Ubuntu, or another distribution.
  3. Install Ruby in WSL:
    • Open the Linux terminal and type:
      bash
      sudo apt update
      sudo apt install ruby-full
    • Check your Ruby installation by running ruby -v.

Installing Ruby on macOS

macOS users can install Ruby using either the Homebrew package manager or by manually installing Ruby from source.

Method 1: Installing Ruby with Homebrew

  1. Install Homebrew (if not already installed):
    • Open Terminal and paste:
      bash
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install Ruby Using Homebrew:
    • In Terminal, type:
      bash
      brew install ruby
    • This installs the latest stable version of Ruby.
  3. Update Your PATH:
    • To make sure Ruby is accessible from anywhere, update your PATH:
      bash
      echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
      source ~/.zshrc
  4. Verify Installation:
    • Check the Ruby version by typing ruby -v in Terminal.

Method 2: Installing Ruby with rbenv (Version Management)

  1. Install rbenv:
    • First, install rbenv using Homebrew:
      bash
      brew install rbenv
  2. Set Up rbenv:
    • Add rbenv to your shell:
      bash
      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
      echo 'eval "$(rbenv init -)"' >> ~/.zshrc
      source ~/.zshrc
  3. Install Ruby with rbenv:
    • Use rbenv to install a specific version of Ruby:
      bash
      rbenv install 3.0.0
      rbenv global 3.0.0
  4. Verify:
    • Run ruby -v to confirm that the correct Ruby version is installed.

Installing Ruby on Linux

Method 1: Using the Package Manager

On Linux, you can easily install Ruby through your package manager.

  • For Ubuntu/Debian:
    bash
    sudo apt update
    sudo apt install ruby-full
  • For Fedora:
    bash
    sudo dnf install ruby
  • For Arch Linux:
    bash
    sudo pacman -S ruby

Method 2: Using rbenv on Linux (Recommended for Version Management)

  1. Install Dependencies:
    • Run the following to install dependencies:
      bash
      sudo apt update
      sudo apt install -y git-core zlib1g-dev build-essential libssl-dev \
      libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev \
      libcurl4-openssl-dev software-properties-common libffi-dev
  2. Install rbenv and ruby-build:
    • Clone rbenv and ruby-build repositories:
      bash
      git clone https://github.com/rbenv/rbenv.git ~/.rbenv
      git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
  3. Set Up rbenv:
    • Update your shell configuration:
      bash
      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
      echo 'eval "$(rbenv init -)"' >> ~/.bashrc
      source ~/.bashrc
  4. Install Ruby Using rbenv:
    • Choose a Ruby version and install:
      bash
      rbenv install 3.0.0
      rbenv global 3.0.0
  5. Verify Installation:
    • Run ruby -v to check the version.

Setting Up Ruby Development Environment

Once Ruby is installed, consider setting up essential tools to streamline your development:

  1. RubyGems: RubyGems is a package manager that comes with Ruby. Use gem install to install libraries and frameworks.
  2. Bundler: Bundler is a tool to manage dependencies, ensuring that your application always has the correct gems installed.
    bash
    gem install bundler
  3. Rails (optional): If you’re interested in web development, install Rails:
    bash
    gem install rails
    Installing Ruby on Windows, macOS, or Linux is straightforward with the right instructions. By setting up Ruby on your system, you’re ready to dive into Ruby programming and explore everything the language offers.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *