.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.

What opens 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.

Windows

  • VS Code
  • RubyMine
  • any text editor

macOS

  • VS Code
  • RubyMine
  • any text editor

Linux

  • VS Code
  • vim
  • any text editor

Open a .rb file step by step

  1. Confirm the file really is a .rb. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with VS Code or RubyMine.
  3. On Mac, use VS Code or RubyMine.
  4. On Linux, try VS Code or vim.
  5. Still stuck? Search for a dedicated Ruby viewer rather than a generic one.

Why can't I open my .rb file?

Almost always because no installed app understands Ruby. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .rb at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

Ruby has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

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. How sources are ranked and what is deliberately left out is set out in the methodology.