Codectionary / Developer documentation / Ruby

Choose a maintained Ruby release, install RubyInstaller with Devkit, verify Ruby in PowerShell and run your first script.

Choose a maintained release

Ruby is the language; RubyInstaller packages a Windows build of Ruby and, in its Ruby+Devkit edition, tools needed to compile native gem extensions. A gem is a reusable Ruby package. The Devkit is useful even if your first script does not need it, because some common gems do. It is not a separate Ruby language.

Check the Ruby website’s branch status and the RubyInstaller downloads page before choosing. Pick a stable, maintained Ruby release compatible with your project or course; avoid preview releases and end-of-life branches for a new project. The exact current release changes, so this guide does not pin a version. For most modern Windows PCs, RubyInstaller recommends the x64 Ruby+Devkit package. Choose another architecture only when your machine or a required dependency calls for it.

Install RubyInstaller and development tools

Download Ruby+Devkit from the official RubyInstaller site and run its installer. Follow the installer’s PATH option so new terminals can find ruby and gem. Keep the Devkit option if you expect to install gems with native extensions; follow the installer’s MSYS2 setup prompt, or use the supplied ridk install tool afterward if setup was deferred. Install only the components the installer recommends for your selected Ruby release.

Close and reopen PowerShell after installation so it reads the updated PATH. A RubyInstaller patch update within the same release line can generally use a newer installer; for a different major or minor Ruby line, follow RubyInstaller’s guidance to use a separate target directory and reinstall gems as needed. Do not overwrite Windows system folders or manually copy Ruby executables.

Verify Ruby in PowerShell

Run ruby --version to check that the terminal finds Ruby, then gem --version to check RubyGems. Get-Command ruby shows which executable PowerShell will use. If more than one Ruby appears, inspect the selected path before changing it: an older installation may still be first on PATH.

A version number means the command is reachable, not that every development dependency is installed. If a later gem reports a missing compiler or MSYS2 component, revisit the RubyInstaller Devkit setup rather than changing permissions on system directories.

PowerShell — inspect the selected Ruby

ruby --version
gem --version
Get-Command ruby

Write and run a first script

Create a folder for your practice files and save hello.rb as plain text containing the Ruby line below. In PowerShell, change to that folder and run ruby hello.rb. The .rb extension identifies a Ruby source file; puts prints the greeting and a newline. The expected output is Hello, Codectionary!. This does not require Rails or any gems.

When a filename contains spaces, quote the path in PowerShell. Save the file as hello.rb, not hello.rb.txt; some editors hide extensions by default.

hello.rb

puts "Hello, Codectionary!"

PowerShell — run the saved file

ruby hello.rb

PATH, Devkit and WSL problems

If PowerShell says ruby is not recognised, reopen the terminal and check Get-Command ruby. Confirm that RubyInstaller completed and its PATH option was enabled. If an older Ruby runs instead, inspect Windows PATH and remove or reorder only obsolete Ruby entries you recognise; avoid replacing other applications’ paths. A native gem build error is different from a missing ruby command: check the installer’s MSYS2/Devkit instructions and the gem’s own requirements.

Windows Subsystem for Linux (WSL) can be useful when your course or deployment expects Linux tooling. WSL runs a separate Linux environment: install Ruby inside that environment using the Linux guide, and run its commands from the WSL shell. A Windows RubyInstaller installation does not automatically become the Linux Ruby inside WSL.

Syntax

ruby --version
ruby hello.rb

Examples

Run a Windows Ruby script

Save as hello.rb and run ruby hello.rb in PowerShell.

puts "Hello, Codectionary!"
  1. puts is a Ruby method that writes a line to standard output.
  2. The quoted text is a String value passed to puts.
  3. Ruby reads hello.rb and displays Hello, Codectionary! in the terminal.

Best practices

  • Choose a maintained Ruby branch compatible with your project.
  • Use the official RubyInstaller download and keep Devkit for gems that compile native code.
  • Open a new terminal after installation and confirm which Ruby is on PATH.

Runtime & versions

Ruby interpreter. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Ruby documentation

Specifications & further reading