Bottom Line: It is 100% safe to clean up the RubyGems cache. Running gem cleanup will NOT delete active Ruby application code or your Gemfile.lock.
What is the RubyGems Cache Folder?
Located at ~/.gem/ruby (or /Library/Ruby/Gems on macOS), this directory is used by RubyGems and Bundler (the package manager for Ruby and Ruby on Rails).
When you run bundle install, RubyGems downloads cached .gem tarballs into cache/ and installs compiled gem extensions. Over time, as Ruby applications update dependencies, old gem versions remain installed on disk, taking up 5 GB to 15 GB+.
Can You Delete RubyGems Cache?
✅ Yes, it is safe to clean up.
- No Rails code risk: Your application source code and
Gemfileremain 100% safe. - Purges obsolete versions: Running
gem cleanupautomatically removes older, unused gem versions while retaining the latest version.
How to Safely Clean Up RubyGems Cache
Method 1: Using the RubyGems CLI (Recommended)
- Open your terminal.
- Remove all outdated gem versions:
gem cleanup - Purge cached
.gemdownload archives:rm -rf ~/.gem/ruby/*/cache/*.gem
Related Guides
- Learn about deleting CocoaPods cache.
- How to clean up pip cache.
- Check if you can clean Composer cache.
Discussion
Loading authentication...