Reputation: 7569
I need to package Ruby application (a batch job), and distribute to other users. Ideally I don't need user to setup Ruby, and the package shall contain all the dependencies in it.
Is there easy way to do this? I am using Ruby v1.9.3.
Upvotes: 0
Views: 325
Reputation: 864
Your not clear in your question, so I'll assume the following are true:
Given that, your best bet is probably the 'ocra' gem. With it you can package your script into an .exe using ocra <script>.rb
. That will bundle your Ruby runtime, any gems your script uses, and your source into a <script>.exe
file, like so:
C:\Users\Walton>cat hello.rb
puts 'Hello World!'
C:\Users\Walton>ocra hello.rb
=== Loading script to check dependencies
Hello World!
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467: Use RbConfig instead of obsolete and deprecated Config.
=== Including 52 encoding support files (5179608 bytes, use --no-enc to exclude)
=== Building hello.exe
=== Adding user-supplied source files
=== Adding ruby executable ruby.exe
=== Adding library files
=== Compressing 14898286 bytes
=== Finished building hello.exe (3261400 bytes)
C:\Users\Walton>hello.exe
Hello World!
Since it packages your existing ruby runtime, you should probably be running a 32-bit Ruby to ensure that your executable can run on both 32 and 64-bit platforms.
If you need something more than ocra can provide, your best bet is going to be to build an installer that packages Ruby and your application.
Upvotes: 3