background preloader

Ruby to Application

Facebook Twitter

Building a Windows executable from my Ruby app. Distributing your Ruby program as a standalone executable (exe) Since ruby is an interpreted language, whenever you want to release your program you need to release the source code.

Distributing your Ruby program as a standalone executable (exe)

Also your program users must install Ruby virtual machine before they can run your program. Is there a way to distribute ruby program as a standalone executable? Erik Veenstra has created a nifty tool called RubyScript2Exe which can convert your ruby program to an executable program. It achieves this by combining ruby interpreter code and your source code files into a single exe file. First download the RubyScript2Exe tool from here. Puts "Hello World" From the command prompt, type the following, ruby rubyscript2exe helloworld.rb You will see the following output on console. The only problem with this executable is that it contains the entire ruby VM and hence is large (helloworld.exe size is around 1.5MB). RubyScript2Exe can also create executable files for Linux and Mac OS X (Darwin).

Ruby Script to .exe. Access Denied. A Ruby Compiler Tue May 29 20:09:00 UTC 2007Erik Veenstra <rubyscript2exe@erikveen.dds.nl> PDF version (A4) 1.

Access Denied

Introduction 2. 3. 4. 5. 6. 7. RubyScript2Exe transforms your Ruby application into a standalone, compressed Windows, Linux or Mac OS X (Darwin) executable. Because of the gathering of files from your own Ruby installation, RubyScript2Exe creates an executable for the platform it's being run on. And when I say Windows, I mean both Windows (RubyInstaller, MinGW and MSWin32) and Cygwin. There is one more advantage: Because there might be some incompatibilities between the different Ruby versions, you have to test your application with every single version. RubyScript2Exe can handle simple scripts, but it can handle complete directories as well. What's the difference between RubyScript2Exe and AllInOneRuby?

If you like RubyScript2Exe, you might want to read Distributing Ruby Applications. (I'm working on full support of RubyGems. Compiling Your Ruby App with RubyScript2Exe. I've mentioned RubyScript2Exe previously.

Compiling Your Ruby App with RubyScript2Exe

This tool allows you to 'compile' a script/application into a portable executable file (EXE) that you can easily provide to your users without requiring them to install Ruby and the required libraries. RubyScript2Exe traces and gathers all the necessary files, including the Ruby interpreter, and 'compiles' them into a single EXE file. You can easily embed images and icon files, and DLLs such as SQLite. I put the word 'compile' in quotes above because RubyScript2Exe does not transform your code as a C compiler or .Net compiler would. Rather, it collects all the files necessary to run your application and bundles them into a single EXE file. Installing RubyScript2Exe is as easy as falling off a log, thanks to RubyGems.

Gem install rubyscript2exe Include the following require statement at the top of your script: require 'rubyscript2exe' Whenever possible, include all your require statements at the top of your script. RUBYSCRIPT2EXE.rubyw = true. OCRA: One-Click Ruby Application Builder. I recently mentioned the fact that RubyScript2Exe 0.5.3 doesn't play well with recent versions of RubyGems.

OCRA: One-Click Ruby Application Builder

At the end of that post I mentioned that there are alternatives emerging for creating executables from your Ruby code, including Lars Christensen's OCRA, the One-Click Ruby Application Builder. I've had a chance to take OCRA for a short test drive and it looks promising. Like Erik Veenstra's RubyScript2Exe, OCRA lets you "compile" your ruby code into an EXE file that you can distribute to others, without requiring that the users have Ruby installed on their PCs. To quote the OCRA page: The executable is a self-extracting, self-running executable that contains the Ruby interpreter, your source code and any additionally needed ruby libraries or DLL.

OCRA can be installed via RubyGems: open a console window and type: gem install ocra It's also available from the RubyForge page. The syntax to compile a script is... ocra.rb [option] your/script.rb ocra.rb myscript.rbw Thanks for stopping by!