Skip to content

When all you need is a rake

When all you need is a rake, why would you grab a tractor?

I have been doing some investigations of build tools lately.  My simple desires for a build tool are:

  • smallish size
  • no installation
  • as much ancillary benefit as possible

I have used NAnt extensively and dabbled in psake recently.  I may post my thoughts on psake later, but at this moment, I want to document what I have done with rake.

My business partner, John Teague, had been pushing me to try Ruby and rake for some time, but I knew the installation had a footprint over 20MB.  Disk space is cheap, but that is still quite an increase over NAnt.  Compound this with how many times it will be downloaded by developers and a Continuous Integration server as part of a build and the size and time adds up.  There is definitely a lot of Ruby development going on, but the size and required installation (Ruby itself plus lots of little “gems”) were real turn-offs.

One evening I started surfing on Ruby and ran across Erik Veenstra’s AllInOneRuby script.  It is a Ruby script that packages your Ruby installation into a single executable.  This is definitely worth a try.  However, I quickly ran into trouble with a run-time error in the script.  The script has not seen an update in two years, so Ruby has apparently moved beyond it.  A lilttle digging and I found the accepted solution to the error.  Nothing like learning a new language by fixing an error in two year source.

This being my first work in Ruby, I am open to constructive criticism.  I will describe the process in two parts.  Specific version numbers are given for reference.  First, the Ruby installation:

  1. I downloaded the latest Ruby binaries (1.8.7) rather than use the Windows installer to maintain the “cleanliness” of my workstation for subsequent testing.
  2. Extract the binaries to c:\rubywork\ruby
  3. Download RubyGems (1.3.4)
  4. Extract RubyGems to c:\rubywork\gems
  5. To install RubyGems, at a command prompt in c:\rubywork\gems, run
    ..\ruby\bin\ruby setup.rb
  6. Download Rake (0.8.7)
  7. Extract Rake to c:\rubywork\rake
  8. To install Rake, at a command prompt in c:\rubywork\rake, run
    ..\ruby\bin\ruby install.rb

Next, to update Erik’s script:

  1. Download allinoneruby.tar.gz (0.2.11), the internals of AllInOneRuby
  2. Extract allinoneruby.tar.gz to c:\rubywork\oneruby\allinoneruby
  3. Download Erik’s tar2rubyscript.rb (0.4.8) to c:\rubywork\oneruby
  4. Edit c:\rubywork\oneruby\allinoneruby\init.rb and modify line 188 to read:
    f.puts ”    $0 = script”
  5. Edit c:\rubywork\oneruby\tar2rubyscript.rb and modify line 623 to read:
    $0 = File.expand_path(“./init.rb”)
  6. At a command prompt in c:\rubywork\oneruby, run
    ..\ruby\bin\ruby tar2rubyscript.rb allinoneruby/
    which will create a partially flawed allinoneruby.rb
  7. Edit c:\rubywork\oneruby\allinoneruby.rb and modify line 605 to read:
    $0 = File.expand_path(“./init.rb”)
  8. At a command prompt in c:\rubywork\oneruby, run
    ..\ruby\bin\ruby allinoneruby.rb –site
    which creates the desired allinoneruby.exe.

The exe is just over 3MB.  Not bad at all.

Now, to execute rake, we need a couple support files.  Create a file named rake.rb:
require ‘rake’
require ‘rake/tasklib’

Then, a file named rakefile:
task :default do
$stderr.puts “Howdy, World”

Place these two files together with your allinoneruby.exe and execute:
allinoneruby.exe ruby.rb
and receive a Texan salutation.


Published inUncategorized