If you need to uninstall Ruby from your Mac, the safest method is to remove only the Ruby versions you installed manually, leaving the system Ruby that Apple includes untouched. This guide covers the exact commands for removing Ruby installed via Homebrew, rbenv, RVM, and the official installer, plus how to clean up leftover files.
Why Uninstall Ruby on Mac?
Ruby is a programming language that many Mac users install for web development (Rails, Jekyll) or command-line tools. You might want to remove it because you no longer need it, you’re switching to a different version manager, or you’re cleaning up your system. However, macOS ships with a pre-installed Ruby at /usr/bin/ruby that Apple uses for system scripts. Removing that system Ruby can break system tools, so this guide focuses on removing user-installed Ruby versions.
Check How Ruby Was Installed
Before uninstalling, find out which Ruby you’re using. Open Terminal and run:
which ruby
This shows the path to the active Ruby. Common paths and their installers:
/usr/bin/ruby– Apple’s system Ruby (do not remove)/usr/local/opt/ruby/bin/ruby– Homebrew-installed Ruby~/.rbenv/shims/ruby– rbenv-managed Ruby~/.rvm/rubies/ruby-x.x.x/bin/ruby– RVM-managed Ruby/usr/local/bin/ruby– Official installer or other
Also run ruby -v to see the version. If the path starts with /usr/bin, you’re on the system Ruby and should not uninstall it. If it points elsewhere, follow the matching section below.
Uninstall Ruby Installed with Homebrew
If you installed Ruby via Homebrew, removing it is straightforward:
- Open Terminal.
- Run
brew uninstall ruby. This removes the Ruby formula. - If you also want to remove dependencies that are no longer needed, run
brew autoremove. - Check for leftover symlinks with
brew cleanup.
After uninstalling, verify with which ruby. If it still shows a Homebrew path, you may have another Ruby version installed via Homebrew (e.g., ruby@3.0). List all with brew list | grep ruby and uninstall each as needed.
Uninstall Ruby Managed by rbenv
rbenv installs Ruby versions into ~/.rbenv/versions/. To remove one version:
- List installed versions:
rbenv versions. - Uninstall a specific version:
rbenv uninstall 3.2.2(replace with your version). - Remove the rbenv shims directory if you want to fully remove rbenv:
rm -rf ~/.rbenv. - Remove the rbenv initialization lines from your shell config file (
~/.zshrcor~/.bash_profile). Look for lines containingrbenvand delete them.
If you only want to remove Ruby versions but keep rbenv, skip step 3 and 4.
Uninstall Ruby Managed by RVM
RVM (Ruby Version Manager) stores Ruby versions in ~/.rvm/rubies/. To remove Ruby and RVM entirely:
- Remove a specific Ruby version:
rvm uninstall 3.1.0(replace with your version). - To completely remove RVM, run
rvm implode. This deletes all Ruby versions and RVM itself. - Remove RVM from your shell config file by deleting lines containing
rvm. - Delete the RVM folder if it remains:
rm -rf ~/.rvm.
Be careful: rvm implode is destructive and cannot be undone. Make sure you don’t need any gems or projects before running it.
Uninstall Ruby from the Official Installer
If you downloaded Ruby from ruby-lang.org and ran the installer, it typically installs into /usr/local/. There is no uninstaller script, so you must manually remove the files:
- Open Terminal and run
which rubyto confirm the path (e.g.,/usr/local/bin/ruby). - Delete the Ruby binary and related files. If installed via the .pkg, you can run
sudo pkgutil --forget com.ruby-lang.ruby(this only removes the package receipt, not the files). - Remove the Ruby directory. For a typical install, run
sudo rm -rf /usr/local/lib/ruby /usr/local/bin/ruby /usr/local/share/ruby. - Also remove the gem home directory if it exists:
rm -rf ~/.gem.
Because this method is manual, double-check each path before deleting. If you’re unsure, use a package manager instead.
Clean Up Leftover Gems and Config Files
Even after uninstalling Ruby, you may have leftover gems (libraries) and configuration files. To remove gems:
- If you used rbenv or RVM, gems are stored inside the Ruby version directory, so they go away with the Ruby version.
- If you used Homebrew, gems are typically in
/usr/local/lib/ruby/gems/. Remove that directory if it exists. - Delete the user gem directory:
rm -rf ~/.gem. - Remove bundler config:
rm -rf ~/.bundle.
Also check for environment variables in your shell config that reference Ruby (like GEM_HOME or RUBY_VERSION) and remove them.
Frequently Asked Questions
Is it safe to uninstall Ruby on Mac?
It is safe to uninstall Ruby versions you installed yourself, but you should not remove the system Ruby at /usr/bin/ruby. Apple uses it for system scripts and some command-line tools. Removing it can cause errors or break functionality.
How do I know if Ruby is installed via Homebrew or rbenv?
Run which ruby and look at the path. If it contains homebrew or /usr/local/opt, it’s Homebrew. If it contains .rbenv, it’s rbenv. If it’s /usr/bin/ruby, it’s the system Ruby.
Will uninstalling Ruby delete my Rails projects?
No. Uninstalling Ruby removes the Ruby interpreter and gems, but your project files (Rails apps, scripts) remain on your disk. However, those projects won’t run until you reinstall Ruby or use a version manager.
What is the difference between uninstall and implode in RVM?
rvm uninstall removes a specific Ruby version but keeps RVM installed. rvm implode removes RVM entirely, including all Ruby versions and gems. Use implode only if you want to completely remove RVM from your system.
Can I reinstall Ruby after uninstalling?
Yes. You can reinstall Ruby using the same method you originally used (Homebrew, rbenv, RVM) or the official installer. If you removed a version manager, reinstall it first, then install Ruby.
Do I need to uninstall Ruby before installing a new version?
No. It’s better to use a version manager like rbenv or RVM to switch between Ruby versions. You can have multiple versions installed and choose which one to use per project. Uninstalling is only necessary if you want to free up disk space or remove a broken installation.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Access the DOM in Angular Safely
- Websites Create QR Code? How It Works
- Evaluate Private Cloud AI Security Operations Platforms
- Space Engineers Server Name & Description Setup
- Tongue Escape Events Schedule: Full Guide
- f/2.8 Telephoto Zoom: What to Consider