Uninstall Ruby on Mac
How to completely remove Ruby on a Mac if it was installed with Homebrew, RVM, rbenv, chruby, rv, mise, or asdf.
I've written a guide to Install the Latest Ruby Version. It is just as important to know how to completely remove Ruby, with instructions here.
Before you get started
You'll need a terminal application to uninstall Ruby. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.
Why uninstall Ruby
Here are reasons you may need this article:
- You're not sure how Ruby was installed on your Mac.
- The Ruby version that runs is not the version you want (use
ruby -vfor version information). - You've got the Homebrew package manager and it automatically updated Ruby to a newer version.
- You need a different Ruby version and you don't have a version manager installed.
- You want to use a different version manager (for example, switching to Mise or rv).
- You've installed Ruby previously for an application such as Jekyll and you need to begin development using a different Ruby version (for example, for Rails).
- Ruby isn't behaving as you expect and you want to install it from scratch.
- A Ruby application fails and you want to eliminate all dependencies (including any gems) and start from a clean install.
- You want to intentionally break Ruby applications that may not be using the Ruby version you wish to support.
- You've got Ruby versions you no longer need and you want to free storage space.
Don't remove the system Ruby
Experienced developers don't remove the system Ruby which comes pre-installed on macOS. Instead, you'll set your shell configuration to override or pre-empt the system Ruby after installing Ruby with Homebrew or a version manager. I explain in the article Why You Shouldn't Use macOS System Ruby.
Steps
This is a guide to remove Ruby on a Mac.
- Use
which -a rubyto see how Ruby was installed. - Don't remove the system Ruby!
- Uninstall Ruby (detailed instructions in this guide).
- Update the shell configuration
~/.zshrcfile (if necessary).
How was Ruby installed?
Check how Ruby was installed.
The command which -a ruby will show you where Ruby is installed.
$ which -a ruby
The installation location will show you how Ruby was installed. Results will also show if more than one Ruby executable is installed.
Here is a list of possible results.
The system Ruby
$ which -a ruby
/usr/bin/ruby
If you see /usr/bin/ruby, it is the system Ruby which comes pre-installed on macOS to support scripting. See the article Why You Shouldn't Use macOS System Ruby. Don't try to remove the system Ruby. Leave it in place and use Homebrew or a version manager to install a newer Ruby version. See the article Compare Ruby Version Managers for recommendations of version managers. Installation of Homebrew or a version manager will require setting your shell configuration to override or pre-empt the system Ruby.
Homebrew
$ which -a ruby
/usr/local/bin/ruby
or
$ which -a ruby
/opt/homebrew/opt/ruby/bin/ruby
If Ruby was installed by Homebrew, you'll see /usr/local/bin/ruby (on Intel silicon) or /opt/homebrew/opt/ruby/bin/ruby (on Apple silicon).
See removal instructions below.
Mise
$ which -a ruby
~/.local/share/mise/installs/ruby/
If Ruby was installed with Mise, it will be in ~/.local/share/mise/installs/ruby/ by default.
See removal instructions below.
rv
$ which -a ruby
~/.local/share/rv/rubies/ruby-4.0.2/bin/ruby
If Ruby was installed with rv, it will be in ~/.local/share/rv/rubies by default.
See removal instructions below.
chruby
$ which -a ruby
~/.rubies/
If Ruby was installed with chruby (with the ruby-install utility), it will be in ~/.rubies/ by default.
See removal instructions below.
asdf
$ which -a ruby
~/.asdf/shims/ruby
If Ruby was installed with asdf, you will see the ~/.asdf/shims/ruby directory.
Ruby versions are installed by default in ~/.asdf/installs/ruby.
See removal instructions below.
rbenv
$ which -a ruby
~/.rbenv/versions/
If Ruby was installed with rbenv (with the ruby-build utility), it will be in ~/.rbenv/versions/ by default.
See removal instructions below.
RVM
$ which -a ruby
~/.rvm/rubies/
If Ruby was installed with rvm, it will be in ~/.rvm/rubies/ by default.
See removal instructions below.
frum
$ which -a ruby
/var/folders/...
If Ruby was installed with frum, it will be in /var/folders/... by default.
See removal instructions below.
Uninstall Ruby with Homebrew
Homebrew is a package manager, not a version manager. It only installs one version of Ruby. You cannot switch among Ruby versions with Homebrew. See your options to Install the Latest Ruby Version if you need to switch among Ruby versions.
Before removing Ruby, run diagnostics
Run a diagnostic to list all the packages you've installed with Homebrew. You should see Ruby and its dependencies.
$ brew list
==> Formulae
libyaml openssl@3 ruby
You can also display a list of packages with their dependencies.
$ brew deps --tree --installed
ruby
├── libyaml
└── openssl@3
└── ca-certificates
Finally, you can see a list of Ruby files installed with Homebrew. This example is from Homebrew on Apple silicon, where Homebrew files are installed in /opt/homebrew.
$ brew list ruby
brew list ruby
/opt/homebrew/Cellar/ruby/4.0.2/bin/bundle
/opt/homebrew/Cellar/ruby/4.0.2/bin/bundler
/opt/homebrew/Cellar/ruby/4.0.2/bin/erb
/opt/homebrew/Cellar/ruby/4.0.2/bin/gem
/opt/homebrew/Cellar/ruby/4.0.2/bin/irb
/opt/homebrew/Cellar/ruby/4.0.2/bin/minitest
/opt/homebrew/Cellar/ruby/4.0.2/bin/racc
/opt/homebrew/Cellar/ruby/4.0.2/bin/rake
/opt/homebrew/Cellar/ruby/4.0.2/bin/rbs
/opt/homebrew/Cellar/ruby/4.0.2/bin/rdbg
/opt/homebrew/Cellar/ruby/4.0.2/bin/rdoc
/opt/homebrew/Cellar/ruby/4.0.2/bin/ri
/opt/homebrew/Cellar/ruby/4.0.2/bin/ruby
/opt/homebrew/Cellar/ruby/4.0.2/bin/syntax_suggest
/opt/homebrew/Cellar/ruby/4.0.2/bin/test-unit
/opt/homebrew/Cellar/ruby/4.0.2/bin/typeprof
/opt/homebrew/Cellar/ruby/4.0.2/include/ruby-4.0.0/ (194 files)
/opt/homebrew/Cellar/ruby/4.0.2/lib/libruby.4.0.dylib
/opt/homebrew/Cellar/ruby/4.0.2/lib/pkgconfig/ruby-4.0.pc
/opt/homebrew/Cellar/ruby/4.0.2/lib/ruby/ (5126 files)
/opt/homebrew/Cellar/ruby/4.0.2/lib/libruby.dylib
/opt/homebrew/Cellar/ruby/4.0.2/sbom.spdx.json
/opt/homebrew/Cellar/ruby/4.0.2/share/emacs/site-lisp/ruby/ruby-style.el
/opt/homebrew/Cellar/ruby/4.0.2/share/man/ (2 files)
/opt/homebrew/Cellar/ruby/4.0.2/share/ri/ (13955 files)
Remove Ruby and dependencies from Homebrew
You can uninstall Ruby from Homebrew with brew uninstall --force ruby:
$ brew uninstall --force ruby
The brew autoremove command will remove unused dependencies.
$ brew autoremove
After removing Ruby, run diagnostics
Run Homebrew diagnostics to confirm you've uninstalled Ruby from Homebrew.
$ brew list | grep ruby
==> Formulae
$ brew list ruby
Error: No such keg: /opt/homebrew/Cellar/ruby
Remove artifacts
You should also remove the shell configuration that gives the Ruby version installed by Homebrew priority over the system Ruby. Open the ~/.zshrc file with a text editor and remove the lines shown below.
On Apple Silicon (M-series):
if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
export PATH=/opt/homebrew/opt/ruby/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi
On Mac Intel:
if [ -d "/usr/local/opt/ruby/bin" ]; then
export PATH=/usr/local/opt/ruby/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi
If you need to reinstall Ruby with Homebrew, see Install Ruby with Homebrew.
Uninstall Ruby with Mise
If you have installed Ruby using Mise, first list all installed versions.
$ mise list ruby
Then uninstall any version.
$ mise uninstall [email protected]
You may also want to remove Ruby from your Mise configuration file (.mise.toml or the global ~/.config/mise/config.toml).
If you want to reinstall Ruby with Mise, see Install Ruby with Mise.
Uninstall Ruby with rv
If you have installed Ruby using rv, Ruby versions are stored in the ~/.local/share/rv/rubies/ directory.
List installed versions:
$ rv ruby list
Remove a Ruby version:
$ rv ruby uninstall 4.0.2
If you want to reinstall Ruby with rv, see Install Ruby with rv.
Uninstall Ruby with chruby
Chruby installs versions of Ruby in the ~/.rubies/ folder, so version 4.0.2 is in the ~/.rubies/ruby-4.0.2 folder. Gems for the version are in the ~/.gem/ruby/4.0.2/gems folder.
If you wish to remove a Ruby version, you can run:
$ rm -rf ~/.rubies/ruby-4.0.2
$ rm -rf ~/.gem/ruby/4.0.2
If you want to reinstall Ruby with chruby, see Install Ruby with Chruby.
Uninstall Ruby with asdf
If you have installed Ruby using asdf, first list all installed versions.
$ asdf list ruby
4.0.2
Then uninstall any version.
$ asdf uninstall ruby 4.0.2
You may want to remove the asdf ~/.tool-versions file that sets the default versions.
If you want to reinstall Ruby with asdf, see Install Ruby with Asdf.
Here's a guide if you need to Uninstall Asdf.
Uninstall Ruby with rbenv
For rbenv, use rbenv versions to see which versions you have installed.
Use the uninstall command to remove a version.
$ rbenv versions
4.0.2
$ rbenv uninstall 4.0.2
This will remove any gems associated with the version as well.
If you want to reinstall Ruby, see Install Ruby on Mac for recommendations of newer version managers.
Uninstall Ruby with RVM
There are two ways to remove rubies from RVM:
rvm removeremoves Ruby and cleans up most of the installrvm uninstallremoves only Ruby (leaves anything else)
rvm uninstall just removes the folder under ~/.rvm/rubies. In most cases, you should use rvm remove. For example:
$ rvm list rubies
ruby-4.0.2
$ rvm remove ruby-4.0.2
If you want to reinstall Ruby, see Install Ruby on Mac for recommendations of newer version managers.
Uninstall Ruby with frum
For frum, use frum versions to see which versions you have installed.
Use the uninstall command to remove a version.
$ frum versions
4.0.2
$ frum uninstall 4.0.2
This will remove any gems associated with the version as well.
Frum is no longer maintained (the last update was in November, 2021). I now recommend Mise or rv.
You can uninstall frum:
$ brew uninstall frum
Continue setting up your Mac
Don't miss the full visual roadmap and checklist that shows how to set up a Mac for software development, with all the essential tools and settings you might not yet know about.