Compile Ruby Script into Exe

Creating Windows executable for ruby APP

So Finally I got the answer, So Travelling ruby does't work for me because some of its limitations

So its good to go with Ocra Gem (https://github.com/larsch/ocra)

Simple install the gem on windows (I have made app on window)
and run the command

ocra <Ruby file name > --verbose --gem-full --no-dep-run --add-all-core --gemfile Gemfile

It will generate the exe file and you are ready to run it on any windows

Packaging Ruby into a portable executable

I got so tired of this that I decided to make my own solution to it. After a couple of days I finally got this working.


I present: Ruby Ship

It's just what I needed, and hopefully someone else will get the benefit of it too!

It's really simple: Download the repo (which is quite big because of the binaries). Put it on a usb-drive, or wherever you want it, then do:

path/to/ruby_ship/bin/ruby_ship.sh -v
=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

That's for linux and mac, or on windows:

path\to\ruby_ship\bin\ruby_ship.bat -v
=> ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mswin32_100]

The ruby_ship wrapper acts just as your normal ruby, so you can pass in a script, or do anything you would use the normal ruby command for.

If you don't like the version that comes bundled with Ruby Ship, then simply use the compiling-script that is in the tools directory. Download the source code of you favourite version of Ruby, say X.Y.Z, then do this:

# *nix (osx/linux/...)
path/to/ruby_ship/tools/ruby_ship_build.sh path/to/ruby-X.Y.Z.tar.gz

# windows
path\to\ruby_ship\tools\ruby_ship_build.bat path\to\ruby-X.Y.Z.tar.gz

This will build your flavour of ruby and set up the wrappers correctly. Now you Ruby version X.Y.Z is portable! Copy paste this folder where you want it and you are ready to go! Remember though, it will only compile for your current platform, so if you need other platforms, go compile it on those platforms as well.

The compiling process has a few requirements. Look at the github site.

Anyways, hope that others might find this useful! If things are not quite working for you, please make an issue and I will look into it!

Can ruby scripts be precompiled into a binary?

Have you checked whether Rubinius or JRuby would allow you to precompile your code?

Is it possible to convert a Ruby script to an .exe so that the source code is not visible?

If you use RubyScript2Exe, your source code can always be read. The explanation is in "Tips & Tricks".

Maybe, like Bobby said, the obfuscation is a better way.
But hiding the source code is often a bad idea.

Making executable file from Ruby program

You could use RubyScript2Exe

http://www.erikveen.dds.nl/rubyscript2exe/

.. it collects all necessary files to run your application on an other machine: the Ruby application, the Ruby interpreter and the Ruby runtime library (stripped down for your application)



Related Topics



Leave a reply



Submit