Folders

How to open .RB files (Ruby scripts) on Android, Windows and Linux

What .rb, .pl, .pm, .lua, .tcl and .coffee files are and how to open, read and edit Ruby, Perl and Lua scripts for free on Android, Windows and Linux.

Cover: Folders' text editor on two phones, labelled .RB

A Rails project lands on your laptop full of .rb files, a game mod comes with a folder of .lua scripts, or an old server has a Perl script nobody has opened in years. You want to see what’s inside before you run or change anything.

These are all plain-text scripts. Folders opens Ruby, Perl, Lua, Tcl and CoffeeScript files in its text editor on Android, Windows and Linux. It shows the code and lets you edit it, but it never runs it.

What is a .rb file?

A .rb file is a script in Ruby, the language Yukihiro Matsumoto (“Matz”) released in the mid-1990s. Ruby is best known for Ruby on Rails, the web framework behind many sites, and for tools such as Homebrew and Jekyll. A Ruby project usually comes with a Gemfile listing its libraries and a Rakefile of tasks. Neither has an extension, and Folders opens both as text.

The other languages here are older or smaller scripting languages that still turn up everywhere:

Extension Language or format What it’s for
.rb Ruby Web apps (Rails), scripts and tools
.pl Perl (or Prolog) Scripts for text processing and system administration
.pm Perl module Reusable Perl code, loaded with use Module::Name
.lua Lua Scripts inside games and programs: mods, add-ons, editor settings
.tcl Tcl Scripts for Tk interfaces, Expect automation and chip-design tools
.coffee CoffeeScript A shorter syntax that compiles to JavaScript

A few notes on each:

  • Perl, created by Larry Wall in 1987, was the glue of early web servers and Unix systems, and many admin scripts still use it. Watch out: Prolog, a logic programming language, also uses .pl. A Prolog file is full of lines like parent(tom, bob)., which Perl code never looks like.
  • Lua comes from a university in Rio de Janeiro and is built to be embedded in other programs. That’s why you meet it in game mods, World of Warcraft add-ons, the LÖVE game engine and Neovim’s init.lua. Roblox uses Luau, a language based on Lua.
  • Tcl (“tickle”) was created by John Ousterhout. Its Tk toolkit draws windows for many programs, including Python’s Tkinter, and Tcl scripts drive a lot of chip-design software.
  • CoffeeScript was popular in the early 2010s and shipped with Rails for a while. Its files have to be compiled into .js before a browser can use them, and most projects have since moved to plain JavaScript.

How to open a .rb file with Folders

On Android

  1. Download Folders from the download section and install it on Android 7.0 or newer.
  2. Open it, tap Allow access, and turn on All files access.
  3. Browse to the script, or search for its name. For game mods, that’s often a folder under Downloads or the game’s mod folder.
  4. Tap the file. It opens in the text editor.

A script attached to a message opens the same way: tap it and choose Open with → Folders. Mods shared as ZIP files can be browsed in Folders, and each script opens with a tap.

On Windows and Linux

  1. Install Folders (Windows installer; deb, rpm, AppImage, Flatpak, Snap or tar.gz on Linux).
  2. Find the file in Folders and double-click it. Folders opens it as text and never runs it.
  3. On Windows, File Explorer’s Open with menu lists Folders for these types: right-click → Open with → Folders.

What you can do with it in Folders

  • Colours that fit the language. Ruby, Perl, Tcl and CoffeeScript files are highlighted with # comments, strings, numbers, keywords and $variables. Lua gets its own colouring, with -- comments and words like local, function, end and nil.
  • Line numbers and Go to line. Ruby’s errors read app/models/user.rb:42:in 'save'; Lua’s read main.lua:17: attempt to index a nil value. Go to line finds the spot.
  • Find and Find and replace, with Match case, to track a variable or change a setting in a mod.
  • Edit and Save with undo and redo, word wrap, and smaller or larger text.
  • Tabs for keeping several scripts open at once.
  • Document info shows the cursor’s line and column, the encoding and the line endings.

Folders doesn’t run, compile or check code. CoffeeScript stays CoffeeScript; it isn’t converted to JavaScript.

Other ways to open .rb files

  • Visual Studio Code, with extensions for Ruby, Perl, Lua and Tcl, on Windows and Linux.
  • RubyMine, JetBrains’ IDE for Ruby and Rails.
  • ZeroBrane Studio, a small free IDE for Lua.
  • The interpreters: ruby script.rb, perl script.pl, lua script.lua, tclsh script.tcl. On Windows, Strawberry Perl and RubyInstaller set these up.

Problems opening a .rb file?

  • The .lua file is gibberish. Some games ship precompiled Lua bytecode instead of source. Open it in Folders’ hex viewer: if the first bytes spell Lua after an escape character, it’s compiled, and there’s no readable code inside.
  • A .pl file doesn’t look like Perl. It may be Prolog. It’s still text, just a different language.
  • Windows tries to run the script. If Perl or Ruby is installed, double-clicking may run it. Use right-click → Open with to read it, or open it from Folders.
  • Perl says it “can’t locate” a .pm module. Perl finds modules by path: My::Tools must be saved as My/Tools.pm inside one of the folders Perl searches. A module that was renamed or moved won’t load, even though the file itself is fine.

Questions people ask

Can I open a .lua file on Android? Yes. Folders opens it with highlighting and line numbers, and you can edit and save it, which is handy for tweaking a mod’s settings.

Is a .lua or .rb file safe? As text, yes. As a program, it can do whatever the game or interpreter allows, so read mods and scripts from unknown sources before using them.

How do I run a .rb file? Install Ruby, then run ruby script.rb in a terminal. For Perl it’s perl script.pl, for Lua lua script.lua.

How do I convert CoffeeScript to JavaScript? Use the CoffeeScript compiler: coffee -c file.coffee writes a .js file next to it. Folders doesn’t convert code.

For Python, see how to open .py files and notebooks. For JavaScript, read how to open JS and TypeScript files. Or browse all 382 file types Folders opens.

Keep reading