OCRA for Ruby Is Outdated: Use OCRAN Instead

If you are looking for OCRA (One-Click Ruby Application) because you want to turn a Ruby script into an .exe, unfortunately OCRA is no longer maintained: its last release, 1.3.11, came out in March 2020, and its changelog lists support for Ruby 2.2 to 2.7. The maintained successor is OCRAN, a fork of OCRA that supports Ruby 3.2 and newer. You use it the same way, with the same options, so switching usually takes a few minutes.

Why OCRAN

OCRA was created by Lars Christensen and was the usual tool for packaging Ruby programs as Windows executables for many years. I maintain OCRAN, which started as a fork of OCRA in 2023, together with other contributors. Besides keeping up with new Ruby versions, OCRAN now also builds executables on Linux and macOS and can output a directory, a zip archive or a macOS app bundle.

Migrating from OCRA to OCRAN

1. Install OCRAN. It requires Ruby 3.2 or newer.

gem install ocran

2. Run ocran instead of ocra. Your existing command line stays the same:

# before
ocra script.rb --output myapp.exe --icon app.ico --gem-full
# after
ocran script.rb --output myapp.exe --icon app.ico --gem-full

What stays the same: all command-line options of OCRA 1.3.11 exist in OCRAN with the same names, for example --output, --icon, --windows, --console, --no-lzma, --gemfile, --no-dep-run, --add-all-core, --chdir-first, --dll, --innosetup, --debug-extract and the --gem-* options. Extra files and arguments after -- work as before. Dependency detection still works by running your script during the build.

What differs: if your code refers to OCRA by name, rename it.

OCRA OCRAN
ENV["OCRA_EXECUTABLE"] ENV["OCRAN_EXECUTABLE"]
defined?(Ocra) defined?(Ocran)
app = MyApp.new
app.main_loop unless defined?(Ocran)

base_dir = File.dirname(ENV["OCRAN_EXECUTABLE"].to_s)

If you are still on Ruby 3.0 or 3.1, note that OCRAN 1.3.17 was the last version supporting them:

gem install ocran -v 1.3.17

More about OCRAN

In my post OCRAN: Turn Ruby Scripts into Executables for Windows, Linux and macOS I describe the output formats, how dependency detection works and what changed in recent versions. The documentation is in the README on GitHub, and problems can be reported in the issue tracker.