The error message: “you don’t have write permissions for the /Library/Ruby/Gems/2.6.0 directory” usually appears on macOS when trying to install a Ruby gem globally using the system Ruby, which is protected by macOS for security reasons.
🔧 How to Fix It
You have several options depending on what you’re comfortable with. Here are the safest and most common solutions:
✅ Option 1: Use sudo (Not recommended for general use)
You can prepend sudo to your command to gain temporary admin rights:
However, this is not recommended long-term because:
It modifies system files
It can break macOS updates or system tools
✅ Option 2: Use a Ruby version manager (Recommended)
Using a version manager like rbenv or RVM allows you to manage and install gems without touching the system Ruby.
📦 Install rbenv (with Homebrew):
Then install your gem:
This installs everything in your user space, avoiding permission issues.

✅ Option 3: Install gems to user space with --user-install
If you only want a quick fix:
Your gems will be installed to:
To use these gems from the command line, add this to your ~/.zshrc or ~/.bash_profile:
Then restart your terminal or run source ~/.zshrc.
🛡️ Final Note:
Modifying system Ruby can lead to unintended consequences on macOS. Using a version manager is the safest and most flexible long-term solution.