Packaging Ruby into a Portable Executable

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!

Create a ruby executable with wxruby for linux

Update: This may not work, because the wxruby gem may use binary "extensions", and that is platform dependent and so may not be easy to get working in Jruby... try and tell

You can try the following workaround with Jruby + warbler gem - it can package your ruby program into a portable JAR (java) file, which you can then copy and run on other computers that have Java installed (only java, ruby will already go packaged in the .jar file :) )

I've made some notes for myself some months ago - they should be enough for the steps involved:

1- install jruby

  • see http://jruby.org/
  • should be as simple as dowload zip file, unzip it, set an environment variable, and execute it (everything is explained it their website, pretty easy)

2- install warbler gem

jruby -S gem install warbler

3- place your .rb files for compile/package with warbler

(see this StackOverflow thread: Create deployable JRuby JAR file? )

mkdir myapp  
mkdir myapp/bin
vim myapp/bin/myapp.rb #create .rb file which will be 'booted' (executed) by jar file
mkdir myapp/lib
vim myapp/lib/my_nice_lib.rb #leave all .rb files to be 'require'd here
cd myapp

4- use warbler to compile/package into myapp.jar

warble jar

5- run myapp.jar in any computer with java, with:

java -jar myapp.jar

Hope it helps - report back how it went

Cheers

Portable Ruby on Rails environment

I like InstantRails, very easy to use, no installer, and does not modify your system environment.

How can I deploy a Perl/Python/Ruby script without installing an interpreter?

You can use Perl Archive Toolkit to bring a minimal perl core + needed modules + your Perl program with you.

And you can even convert it using PAR Packer to a windows exe file that will run just like any other program, from an end user's perspective.

Package nwjs app into a single exe

I did some more research and solved it myself by using Enigma Virtual Box.

http://enigmaprotector.com/en/downloads.html



Related Topics



Leave a reply



Submit