I was having some strange errors in TextMate when trying to run commands that relied on ruby. I had installed ruby and gem with MacPorts, and /opt/local/bin was in my $PATH, but I still got things like this:
`require': No such file to load -- rubygems (LoadError)
Adding this to my .profile seemed to fix it:
export TM_RUBY=/opt/local/bin/ruby
Hopefully this won't be necessary after upgrading to OS X 10.5, as it comes with an up-to-date version of ruby and gem built right in.