Chad Woolley's blog



Chad WoolleyChad Woolley
[ANN] GemInstaller 0.5.3 Released
edit Posted by Chad Woolley on Tuesday August 25, 2009 at 11:25PM

This fixes several bugs that people have complained about for quite a while. Please let me know if anything is broken.


GemInstaller 0.5.3 has been released!

GemInstaller

CHANGES

  • 0.5.3 / 2009-08-25
  • Many long overdue bugfixes and patches, see http://tinyurl.com/geminstaller-0-5-3-release for details.
  • Thanks to Greg Fitzgerald, Britt Crawford, John Trupiano, Gabriel Gironda, and Eric Hodel for patches and assistance.
  • Issues with case statement under Ruby 1.9
  • GemInstaller cannot distinguish between gems that have the ame name but capitalized differently.
  • add ./ci as default location for config file
  • Disable GemInstaller install in default rails preinitializer.rb, but fork if it is used
  • autogem() fails when run for newly-installed gem
  • Sometimes installing fails due to RubyGems cache not being cleared between multiple API calls

DESCRIPTION

Automated Gem installation, activation, and much more!

FEATURES

GemInstaller provides automated installation, loading and activation of RubyGems. It uses a simple YAML config file to:

  • Automatically install the correct versions of all required gems wherever your app runs.
  • Automatically ensure installed gems and versions are consistent across multiple applications, machines, platforms, and environments
  • Automatically activate correct versions of gems on the ruby load path when your app runs ('require_gem'/'gem')
  • Automatically reinstall missing dependency gems (built in to RubyGems > 1.0)
  • Automatically detect correct platform to install for multi-platform gems (built in to RubyGems > 1.0)
  • Print YAML for "rogue gems" which are not specified in the current config, to easily bootstrap your config file, or find gems that were manually installed without GemInstaller.
  • Allow for common configs to be reused across projects or environments by supporting multiple config files, including common config file snippets, and defaults with overrides.
  • Allow for dynamic selection of gems, versions, and platforms to be used based on environment vars or any other logic.
  • Avoid the "works on demo, breaks on production" syndrome
  • Find lost socks.

Quick Start

See http://geminstaller.rubyforge.org/documentation/index.html

INSTALL

  • [sudo] gem install geminstaller

Chad WoolleyChad Woolley
"open_gem" Gem Plugin
edit Posted by Chad Woolley on Saturday May 09, 2009 at 12:50AM

From the Too Useful Not to Blog Department:

open_gem from Adam Sanderson is a new RubyGems Plugin to automatically open a gem's source in your favorite $EDITOR.

gem update --system
sudo gem install open_gem
export EDITOR=mate
gem open rails

NOTE: If you have RubyGems 1.1 or 1.2, 'gem update --system' may not work. See the RubyGems Release Notes for more info.

Chad WoolleyChad Woolley
Removing Old Ruby Source Installation After a Leopard Upgrade
edit Posted by Chad Woolley on Friday February 22, 2008 at 02:38PM

Removing Ruby

I just upgraded to Leopard on my Mac. Previously, on Tiger, I had installed Ruby from source, in the default /usr/local/lib prefix. After reading the discussion on the Apple-provided Ruby installation, I decided to try it - mainly to ensure that my apps, such as GemInstaller, play well with it (on Pivotal's Mac pair workstations, we still install Ruby from source, so everything matches our demo/production environments as closely as possible, and things are in consistent locations).

So, I wanted to uninstall the old Ruby source installation, and only have the Apple-provided Ruby on disk. Googling for a few minutes did not provide exact instructions for this, so I'm writing up what I did, in hopes that it will help you!

I didn't use the "--prefix" option when I originally installed Ruby from source, so it was in the default location of /usr/local/lib/ruby, with binaries in /usr/local/bin.

WARNING: Use 'rm -rf' at your own risk - a sleep-deprived encounter with 'rm -rf' and a stray file named '~' is what "motivated" my Leopard upgrade in the first place...

First, I deleted the old ruby libraries/gems, which was easy enough, because they all lived under /usr/local/bin/ruby:

sudo rm -rf /usr/local/lib/ruby

However, this left all the old ruby/gems executables in /usr/local/bin. This resulted in errors when trying to run executable gems that I had not yet installed under the Apple Ruby installation:

$ cheat
/usr/local/bin/cheat:9:in `require': no such file to load -- rubygems (LoadError)
from /usr/local/bin/cheat:9

Instead of a cryptic rubygems error, I should get a 'file not found error':

$ sudo rm /usr/local/bin/cheat
$ cheat
-bash: /usr/local/bin/cheat: No such file or directory

So, I want to purge everything ruby-releated from my /usr/local/bin folder. I whipped up a quick ruby one-liner which just prints out (almost) all ruby-related files in /usr/local/bin:

ruby -e "old_ruby_execs = \`egrep 'rubygems|bin/ruby|env ruby' /usr/local/bin/*\`; require 'pp'; pp old_ruby_execs.split(\"\n\").collect{|line| line.split(':').first}.uniq"

Yeah, I know, ugly and obtuse, but one-liners are kind of fun, and help me remember that Ruby is great tool for sysadmin scripts. Feel free to put it in a class and test it if you are so inclined.

Even though I tried to make a fairly specific regexp for egrep, when inspecting that list, I did find a 'jgem' file, which was part of JRuby. I'm planning on reinstalling JRuby anyway, so I didn't care if that got deleted along with the other ruby stuff.

Anyway, if the output of that looks like everything you want to delete, then run this one-liner to do the actual deed (the 'sudo echo' is to 'prime' the sudo auth, so you don't get a noninteractive password prompt):

sudo echo; ruby -e "old_ruby_execs = \`egrep 'rubygems|bin/ruby|env ruby' /usr/local/bin/*\`; old_ruby_execs.split(\"\n\").collect{|line| line.split(':').first}.uniq.each { |exec| p 'removing ' + exec; \`sudo rm #{exec}\`}"

After that, the only thing that I saw left was the 'ruby' executable itself, which I whacked as well:

$ sudo rm /usr/local/bin/ruby

That seems to be about it, as least good enough to get all the old invalid executables off my path. I'm sure this could have been done cleaner if I had taken more care with the original source install. However, a good brute-force approach never hurt anyone. Much. Feel free to post links to relevant and helpful stuff.