This method works with:

  1. Rails apps (your portable app will be a webserver);
  2. Scripts with gems;
  3. Multiple source file scripts;
  4. Simple, single source file scripts;

The final app is a single executable file that can run on systems without a ruby interpreter installed.


I developed a gem that automates this process. Check it out:


1. First, let’s create a simple Hello World app:

Part I: Standalone Ruby

2. Your ruby version should be 2.2.2, 64 bits:

If your version is different, please install the 2.2.2 (e.g. “rvm use 2.2.2”).
This will NOT work with 2.2.0, 2.2.3, 2.1, etc.

3. Duplicate the project folder, naming it as “app”:

4. In the project folder, create a “.package/payload/lib/ruby” sub-folder:

5. Move the “app” folder to “.package/payload/lib”

6. Download ruby traveler 2.2.2 64 bits (5.6M), and unzip it on “.package/payload/lib/ruby”:

7. Go back to “.package/payload/”:

8. Create a wrapper script (name it as “installer”):

Replace the “exec” line with your actual command to start the application. Eg. for Rails apps, it should be:
RAILS_ENV=production exec “$SELFDIR/lib/ruby/bin/ruby” -rbundler/setup “$SELFDIR/lib/app/bin/rails” server

The above script is based on the “traveling ruby” tutorial.

Part II: Gemfile

If your project has a Gemfile, you need to follow these extra steps:

9. Create a “tmp” folder on “.package/payload/lib”

10. Copy the project Gemfile to tmp

11. Download gems into the “lib/vendor” folder

12. Delete tmp folder

13. [Optional] Delete gem’s cache in the vendor folder

14. Copy the Gemfile to the vendor folder

15. Create a bundler config

Part III: Pack everything as a single self-extract file

This part is based on this Jeff Parent’s article.

17. Create a script to decompress everything

18. Package builder

And that’s it. You can now rename and distribute the generated “output” file :)