.rb

What is a .rb file?

Ruby Source File · Code and data · Yukihiro Matsumoto · 1995

A .rb file is Ruby source code, a dynamic language designed for programmer happiness and readable, expressive syntax. It powers the Ruby on Rails web framework and many automation scripts.

Category
Code and data
Type
Plain text
Is a .rb file safe to open? Caution. A .rb file is a program. Running it executes its code, so read unfamiliar scripts before running them.

What is a .rb file used for?

Ruby reads almost like English and is run by the Ruby interpreter with ruby file.rb. It is the language behind Rails, so many web applications and their build scripts are made of .rb files.

The files are plain text and open in any editor. Ruby is interpreted, so there is no separate compile step; you run the source directly.

How to open a .rb file

The .rb format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .rb file.

Windows

  • VS Code
  • RubyMine
  • any text editor

macOS

  • VS Code
  • RubyMine
  • any text editor

Linux

  • VS Code
  • vim
  • any text editor

.rb file signature (magic bytes)

Programs recognise a .rb file by the bytes at the start of the file, not by its name. These are the signatures for Ruby.

Hex signatureOffsetNote
(no fixed signature)0plain text; no fixed magic bytes

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .rb file?

A .rb file is Ruby source code, a dynamic language designed for programmer happiness and readable, expressive syntax. It powers the Ruby on Rails web framework and many automation scripts.

How do I run a .rb file?

With Ruby installed, run ruby file.rb from a terminal. There is no compile step; the interpreter runs the source directly.

How do I open a .rb file?

Any text editor shows it. VS Code or RubyMine add highlighting and tools for Ruby and Rails projects.

Is Ruby the same as Ruby on Rails?

No. Ruby is the language; Rails is a popular web framework written in Ruby. Rails projects are made largely of .rb files.

Related formats

Sources

Details on this page were checked against authoritative references: