---
title: Managing Ruby Gems using Homebrew
date: 2022-10-03 08:00
slug: managing-ruby-gems-using-homebrew
categories:
- Code
tags:
- ruby
- homebrew
- scripting
---

Whenever I publish a gem like [doing][5678-0001], [howzit][5678-0002], or [na][5678-0003], 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](https://brew.sh) and don't care much about Ruby: [`brew-gem`](https://github.com/sportngin/brew-gem).

[5678-0001]: https://brettterpstra.com/projects/doing
[5678-0002]: https://brettterpstra.com/projects/howzit
[5678-0003]: https://brettterpstra.com/projects/na

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.

---

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff. This content is supported by readers like you. [More about Brett](https://brettterpstra.com/contact.md), including social links.

Copyright © 2026 Brett Terpstra. All rights reserved.
