Korean

ruby — Ruby interpreter

Development / Build / ruby.html

BuildOriginalRegistered 2026-10-20T09:00:00+09:00

The interpreter that runs Ruby scripts.

Basic Information

Command Nameruby
One-line IntroductionThe interpreter that runs Ruby scripts.
Provided byRuby
Official Documentationhttps://docs.ruby-lang.org/en/master/
Supported Operating SystemsLinux, macOS, BSD, Windows
Installation StatusInstalled by default or via package
CategoryBuild and compile (tags: Language toolchain (tags: ruby, interpreter, script, gem))

What is this command?

ruby interprets scripts line by line. With no compile step you can iterate quickly, and -e runs a single line while -c only checks syntax.

Libraries are gems, with Bundler pinning per-project versions. Using rbenv or rvm instead of extending the system Ruby reduces conflicts during upgrades.

What problems does it solve?

  • Running small automation scripts
  • Starting Ruby applications such as Rails
  • Checking syntax without executing
  • Isolating Ruby versions per project

Key features

Running scripts

Pass a file to execute it.

  • When to use: Running batch jobs or tooling scripts
  • What you get: You see results immediately.
  • Limitations: An exception aborts the run with a stack trace.

One-liners

The -e option runs a short snippet directly.

  • When to use: Quick string processing or calculations
  • What you get: No file needs to be created.
  • Limitations: Quoting conflicts with the shell require care.

Syntax check

The -c option checks syntax without running.

  • When to use: Validating edited scripts before deployment
  • What you get: Finds errors without side effects.
  • Limitations: It cannot catch runtime errors.

Installation and usage

Check whether it is installed

ruby --version

sudo apt install ruby-full # Debian/Ubuntu sudo dnf install ruby # Fedora

Real-world examples

Run a script

Execute a file.

ruby script.rb

Run a one-liner

Run a short snippet immediately.

ruby -e 'puts [1,2,3].sum'

Syntax check

Check syntax without executing.

ruby -c script.rb