0
0
RubyHow-ToBeginner · 4 min read

How to Install Ruby on Windows: Step-by-Step Guide

To install Ruby on Windows, download the official RubyInstaller from rubyinstaller.org, run the installer, and follow the setup steps. After installation, open Command Prompt and type ruby -v to verify Ruby is installed correctly.
📐

Syntax

The main command to check Ruby installation is:

  • ruby -v: Shows the installed Ruby version.
  • gem install [package]: Installs Ruby packages (gems).

These commands run in the Windows Command Prompt after Ruby is installed.

bash
ruby -v
Output
ruby 3.2.2p53 (2024-03-30 revision 12345) [x64-mingw32]
💻

Example

This example shows how to check Ruby version after installation to confirm it works.

bash
ruby -v
Output
ruby 3.2.2p53 (2024-03-30 revision 12345) [x64-mingw32]
⚠️

Common Pitfalls

Common mistakes when installing Ruby on Windows include:

  • Not adding Ruby to the system PATH during installation, so commands like ruby are not recognized.
  • Installing an outdated RubyInstaller version.
  • Skipping the MSYS2 development toolchain installation, which is needed for some gems.

Always select the option to add Ruby to PATH and install MSYS2 when prompted.

batch
REM Wrong: Not adding Ruby to PATH
ruby -v

REM Right: Add Ruby to PATH during install, then check version
ruby -v
Output
ruby 3.2.2p53 (2024-03-30 revision 12345) [x64-mingw32]
📊

Quick Reference

  • Download RubyInstaller from rubyinstaller.org.
  • Run the installer and check "Add Ruby executables to your PATH".
  • Install MSYS2 development toolchain when prompted.
  • Verify installation by running ruby -v in Command Prompt.

Key Takeaways

Download RubyInstaller from the official site to get the latest stable Ruby for Windows.
Always add Ruby to your system PATH during installation to use Ruby commands anywhere.
Install the MSYS2 toolchain when prompted for full Ruby functionality on Windows.
Verify your installation by running ruby -v in Command Prompt.
Use gem install to add Ruby packages after installation.