How to execute your Ruby scripts on a machine without Ruby 3

Posted by jeff Wednesday, August 02, 2006 14:27:00 GMT

If you need to run a Ruby script on a machine without Ruby, consider RubyScript2Exe if you can’t install Ruby on that machine.

It’s a handy tool, because it will gather up everything your script needs to run on a machine that does not have a ruby interpreter installed. It grabs your Ruby interpreter so you’re guaranteed it will work even if there’s a different version of Ruby already installed on the target machine. Read all about it here.

There are several ways to install RubyScript2Exe. I prefer the gem method. Let’s say I have a script called hockey.rb:

puts "NHL teams are great to watch." 
puts "(except in Chicago, perhaps)" 

Say I now want to run this script on a computer without Ruby. Here’s all it takes:

c:\dev> gem install rubyscript2exe
c:\dev> rubyscript2exe hockey.rb

When you gem install, you end up with a rubyscript2exe.cmd file in your \ruby\bin folder, which is in your PATH.

RubyScript2Exe runs my hockey.rb script, watching for all the dependencies that get pulled in along the way. It’s smart enough to only pull in the Ruby libraries that my script actually uses, so the resulting .exe is as small as possible.

When it’s done:

c:\dev> hockey.exe
NHL teams are great to watch.
(except in Chicago, perhaps)

Some external dependencies get complicated. For example, here’s how you need to wrap up a Ruby application that relies on GTK+.

But for most scripts, you can just run RubyScript2Exe like I did above, put your .exe on maybe a USB key, and run a Ruby program on another PC without ever installing Ruby on that machine at all.

Comments

Leave a response

  1. Chimichanga   August 25, 2006 @ 11:17 AM

    Just found this site. Love how you bashed the Blackhawks in this lesson. Lord knows, they deserve it.

  2. kino   May 24, 2008 @ 01:12 AM

    Our sense perceptions are the clue to the discovery of our sense perceptions; for these reasons, the employment of our faculties would thereby be made to contradict, so far as I know, the transcendental unity of apperception.

  3. Ellroy   May 30, 2008 @ 11:22 PM

    The reader should be careful to observe that, that is to say, our a priori knowledge, in accordance with the principles of the Categories, proves the validity of our understanding, and our speculative judgements are just as necessary as natural causes.

Comment


(won't be published)