Stephen Balkum

Agile Enthusiast, Leader, and Developer
posts - 5, comments - 6, trackbacks - 0

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'
Rake.application.run

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

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

Enjoy!

Print | posted on Tuesday, June 09, 2009 12:32 AM |

Feedback

Gravatar

# re: When all you need is a rake

Nice post, but the urls are not working...
I would definitely try this in my current project. I often looked to ruby, but never got the time/guts to install it and use it for the project...
6/11/2009 1:33 AM | David
Gravatar

# re: When all you need is a rake

Awesome!

The next trick is to find a way of letting Rake tasks talk to .NET objects without COM wrappers or using slow IronRuby :)
6/11/2009 6:26 AM | Tobin Harris
Gravatar

# re: When all you need is a rake

So if you were to need ActiveRecord gem(or any other gem) as a part of the build process, the gem would need to install first, the executable created thereafter and used? Is that right?


Thanks, good work!
6/15/2009 11:03 AM | Joe Gomez
Gravatar

# re: When all you need is a rake

Sorry about the urls not working. That's what I get for trusting this blog tool. They should be good now.
6/15/2009 5:37 PM | sbalkum
Gravatar

# re: When all you need is a rake

That’s great that you do a king of supreme topic just about this good topic. Moreover we opine that this would be very good if some persons order the thesis project and dissertation writing with you help.
1/2/2010 6:25 AM | Lucy29

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 4 and 2 and type the answer here:

Powered by: