How to uninstall Ruby on a Mac, when rbenv, Homebrew and macOS each have one
Our Mac had five Rubies: two in rbenv, two from Homebrew and Apple's own. Which you can remove, how to remove each, and the one to leave alone.
How many Ruby versions do I have?
Run which -a ruby and ls ~/.rbenv/versions. Our Mac had five:
| Ruby | From | Size |
|---|---|---|
| 3.0.0 and 3.2.3 | rbenv, in ~/.rbenv/versions | 182 MB together |
| 3.3.5 and 3.4.4 | Homebrew | 238 MB together |
| Apple's | /usr/bin/ruby | part of macOS |
ruby -v answered 3.0.0, from rbenv, because rbenv's shims came first in the PATH.
How do I uninstall a Ruby version with rbenv?
rbenv uninstall 3.0.0How do I uninstall rbenv itself?
- Remove the
rbenv initline from~/.zshrcand open a new Terminal window. - Move
~/.rbenvto the Trash, which removes every Ruby it installed. brew uninstall rbenv ruby-build.
How do I remove Homebrew's Ruby?
brew uninstall ruby. Check brew uses --installed ruby first: other tools, such as CocoaPods, may need it.
Can I uninstall the Ruby that comes with macOS?
No, and you should not try. /usr/bin/ruby is part of the protected system, and macOS tools use it.
Gems take space of their own: Ruby gems taking up space.
Common questions
Can I delete Ruby on my Mac?
You can remove Rubies you installed with rbenv, rvm or Homebrew. Apple's /usr/bin/ruby is part of macOS and stays.
How do I uninstall rbenv on Mac?
Remove its init line from ~/.zshrc, move ~/.rbenv to the Trash, and run brew uninstall rbenv ruby-build.