macOS: ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory
gem install tries to write into Apple's system Ruby, which is protected and shouldn't be modified.
You don't have write permissions for the /Library/Ruby/Gems directoryGem::FilePermissionError You don't have write permissions for the /Library/Ruby/GemsERROR: While executing gem ... (Gem::FilePermissionError)You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory Meaning
Don't use sudo gem install with the system Ruby. Install a version manager (rbenv, asdf or ruby-build via Homebrew), install Ruby 3.x, and use bundle config set path vendor/bundle for project gems. Cocoapods users can install via Homebrew.
Common causes
- Using Apple system Ruby
- sudo gem workarounds blocked by SIP
- No Ruby version manager
- Rbenv not initialised in shell
- Bundler path unwritable
⚡ Quick fix
brew install rbenv ruby-build && rbenv install 3.3.0 && rbenv global 3.3.0- Add
eval "$(rbenv init - zsh)"to ~/.zshrc bundle config set --local path vendor/bundle
Detailed fix by platform
macOS
which ruby && ruby -v(should be under ~/.rbenv, not /usr/bin)
How to diagnose
- Ruby — System or managed?
- Init — rbenv in shell?
- Path — Bundler path?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- ArgumentError: missing keyword / unknown keyword Ruby: ArgumentError: missing keyword: :name / unknown keyword: :nmae
- ArgumentError: wrong number of arguments (given 1, expected 2) Ruby: ArgumentError: wrong number of arguments (given 1, expected 2..3)
- avc: denied SELinux is preventing ... / avc: denied { read } for pid=... (permission denied despite correct permissions)
Most viewed in macOS
- is damaged and can’t be opened macOS: “App” is damaged and can’t be opened. You should move it to the Trash.
- git: 'credential-osxkeychain' is not a git command Git: git: 'credential-osxkeychain' is not a git command. See 'git --help'
- fork: Resource temporarily unavailable macOS: -bash: fork: Resource temporarily unavailable (process limit reached)
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026