Friday, April 18, 2008

Getting Ruby Gems on Ubuntu

The lack of Gems as a .deb is recurringly annoying.

While I appreciate the reasons for doing so, it doesn't make my life easier.

So here is a script to do it:

gems_version = ARGV[0] unless ARGV[0].nil?
rubyforge_v = "20989"
rubyforge_v = ARGV[1] unless ARGV[1].nil?
puts "installing unpack (unp)"
system("sudo apt-get install unp")
puts "done!"
puts "installing rdoc"
system("sudo apt-get install rdoc")
puts "getting ruby gems version #{gems_version}"
puts "unpacking..."
system("unp #{gems_version}.tgz")
pwd = Dir.pwd
puts "running install"
system("sudo ruby setup.rb")
puts "cleaning up"
system("rm -rf #{gems_version}")
system("rm -rf #{gems_version}.tgz")

All you need to do it grab it, save it to a file, chmod it, run it, and you are done :-).

PS: you need to be logged in as a user who can sudo. Also note the version of gems the script supports if you need to change it you will have to determine the name of the file (minus the .tgz) and also the magic number at which the file sits in the rubyforge repository, which you need to pass to the script respectively as arguments.

No comments: