Take the 2-minute tour ×

I'm trying to package my ruby application as a RubyGem (using Jeweler and Rake). I've some C source which I need to build on the target machine where the gem is to be installed and then place the output in the gem's bin directory so that my ruby code can use it.

Is there any hook by which I can execute commands during gem installation?

A snippet from my Rakefile looks like this:

task :install do
  puts "Install"
  `touch /tmp/install`

task :build do
  puts "Build"
  `touch /tmp/build`

When I execute rake build it outputs Build and when I execute rake install the output is Build followed by Install. The problem comes when I do gem install then the install task is not being called.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You need gemspec extensions:


Basically you can run any ruby code you like when the gem is installed.

share|improve this answer
Great! But it looks like it needs an extconf.rb file and which should result in a Makefile in that directory. –  arrac Dec 16 '10 at 6:58
add comment

Your Answer


