Whenever I publish a gem like doing, howzit, or na, I always suggest that if you have any trouble installing with gem install X, you should use sudo gem install X. This is because the preferred way is to do it without sudo (for multiple reasons), but those who don’t do anything else with Ruby and just want to use tools distributed as gems are almost definitely using the system Ruby, which won’t allow updating its gem folder without sudo. I was recently turned onto another option, though, which is perfect for people who use Homebrew and don’t care much about Ruby: brew-gem.

You can install brew-gem with brew install brew-gem. Once installed, instead of gem install X, you can run brew gem install X, and then your gems will be installed to your Cellar and managed with Homebrew. To upgrade to the latest version of a gem, just run brew gem upgrade X. If you want to use a brew-installed version of Ruby, just add --homebrew-ruby to any install/upgrade command.

This is an ideal solution in a lot of cases. For those not using rbenv, RVM, asdf, or other environment manager, it means not having to use sudo and install your gems to system directories, plus you get update management via Homebrew. Nice. I’ll be updating my various README’s to point to this.