How do I alias a Homebrew installed Ruby 1.9 gem binary in /usr/local/bin?

Homebrew's Ruby 1.9 ships with rubygems. Doing gem install ... installs files and binaries into some long-winded path. For example, bundler is installed at:

/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/bin/bundle

I'd like to have gem automatically symlink these binaries into a common location such as /usr/local/bin so that I don't have to manually link each of these binaries. Is this possible?


Solution 1:

# Install 1 or more gems
gem install rails
gem install aws-sdk
# Then run these 2 commands to create bin links
brew unlink ruby
brew link ruby
# Finally open a new terminal session (no idea why but it worked for me)

Solution 2:

Related question on StackOverflow: Installing Ruby gems not working with Home Brew

This little one-liner works perfect and is faster than querying brew-info:

export PATH=$(brew --prefix ruby)/bin:$PATH

More info in my answer there.