Tuesday, June 23, 2009

Manually Freezing Ruby Gems in OS X

Update: This post is unfortunately a little out-of-date. I now use rvm, so I have to remember not to "sudo". I was never a big fan of sudo'ing each time.

I was having trouble with updating a frozen gem in a project using an older version of rails. I knew enough to move (remove) the dir from /vendor/gems/ dir to unfreeze it (that's what unfreeze does), but ran into a few hiccups along with way of getting the gem I installed back into the /vendor/gems/.

First off, when I first set up ruby, I was told the normal way to do it for our team was to install gems as root, which I'd forgotten. I don't think there is a good reason for it, but I learned that in addition to the normal two places in OS X for gems:
* /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
* /Library/Ruby/Gems/1.8
with the latter being for the ones you'd install, when you don't have rights to those, the gem goes into ~/.gem instead. It provided a warning, but I'd ignored it at first glance:

WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
   /usr/bin aren't both writable.

After doing sudo su root, I reinstalled the gem and I could then find it in /Library/Ruby/Gems/1.8, not that I guess it really mattered where it was.

I could then tar.gz the gem from /Library/Ruby/Gems/1.8 and extract it into my vendor/gems dir.

No comments: