rubycompilationexecutablepackaging

Single executable binary of Ruby gem


What options are available to create a single binary that contains my Ruby gem along with a Ruby runtime?

My goal is to be able to share the executable with another developer and they could simply run the executable from their command line passing it required arguments similar to Vagrant.

P.S. The program is intended to be run in a *nix operating systems with Ruby versions >= 2.5.


Solution

  • There's ruby-packer but the repo has been dead for a while. There are forks with Ruby 2.5. It can produce binaries for Linux, Mac, Windows and probably some others.

    For linux based systems you could use AppImage (there are some scripts found on google that put a ruby in the image) or maybe Snapcraft.

    When you have ruby-packer and the dependencies installed, it's just a matter of rubyc -o binary-name gem-executable-name in the app's directory. Takes about 15 minutes to compile.