Ruby to EXE - Turn ruby scripts into portable executable apps
Clone or download
Daniel Loureiro
Daniel Loureiro Version change
Latest commit 0881bf2 Jan 8, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Check ruby version more consistently Jan 4, 2019
lib Version change Jan 8, 2019
Gemfile First release Sep 24, 2016
LICENSE Add License (public domain) Apr 2, 2017 Version change Jan 8, 2019
Rakefile "-h / --help" double parse fix Jul 27, 2017
rb2exe.gemspec "-h / --help" double parse fix Jul 27, 2017

Ruby to EXE

Turn ruby scripts into portable executable apps.


gem install rb2exe


rb2exe RUBY_SCRIPT [options]
    -q, --quiet                      Do not run verbosely
    -a, --add=FOLDER                 Add an entire folder (eg. "--add=.")
    -i  --ignore-folder=FOLDER       Do not add a folder (default=".git")
    -ao --add-output                 Do not ignore output file when adding files
    -o, --output=OUTPUT              Output executable filename
    -d  --daemon                     Runs the app as a background task
    -r, --rails                      Rails support
    -t, --target=[osx|l32|l64|win]   Target platform (binary)
    -h, --help                       Help


echo "puts 'Hello world'" > test.rb

rb2exe test.rb
# Hello world

Example II - Multi source project

mkdir test
cd test
echo "STR = 'Hello world'" > a.rb
echo "load 'a.rb'" > main.rb
echo "puts STR" >> main.rb

rb2exe main.rb --add=.
# Hello world

Example III - Gemfile support

mkdir test
cd test
echo "source ''" > Gemfile
echo "gem 'faker'" >> Gemfile
echo "require 'faker'" > a.rb
echo 'puts "Hello #{}"' >> a.rb

rb2exe a.rb --add=.
# Hello Abbigail Okuneva

Example IV - Rails support

rails new myproject
cd myproject

rb2exe --rails
# => Booting Puma
# => Rails application starting in production on
# => Run `rails server -h` for more startup options
# Puma starting in single mode...
# * Version 3.6.0 (ruby 2.2.2-p95), codename: Sleepy Sunday Serenity
# * Min threads: 5, max threads: 5
# * Environment: production
# * Listening on tcp://
# Use Ctrl-C to stop

Example V - OSX binary

rb2exe test.rb --target=osx


rb2exe DOESN'T protects your source code.

In fact, the produced executable file contains all the source files and THEY CAN BE EASILY EXTRACTED.

You can see the list of the added source files when you run rb2exe.

rb2exe just packages your source files (plus a stand-alone ruby) in an auto-extract zip file. It doesn't protects your code in any way.


Bug reports and pull requests are welcome on GitHub at


  • 0.3.1: Fixes an "incorrect version" bug
  • 0.3.0: Includes a copy of the file;
  • 0.2.5: Ignore output file when adding files. Add "--add-output" option;
  • 0.2.4: Ignore '.git' folder by default. Add "--ignore-folder" option;
  • 0.2.3: add "--daemon" option;
  • 0.2.1: add missing "bundle" requirement;
  • 0.2.0: adding support to handle ARGV being passed to the ruby script (thanks @dabooze);


  • Windows executable output;
  • Allow ruby versions other than 2.2.2;
  • Testing suite;

You can also take a look on my article, where I explain how this gem works, step-by-step: