You don't have write permissions for the /Library/Ruby/Gems directory macOS Origin: Platform & cloud OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: macOS Ruby

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

  1. brew install rbenv ruby-build && rbenv install 3.3.0 && rbenv global 3.3.0
  2. Add eval "$(rbenv init - zsh)" to ~/.zshrc
  3. bundle config set --local path vendor/bundle

Detailed fix by platform

macOS

  1. which ruby && ruby -v (should be under ~/.rbenv, not /usr/bin)

How to diagnose

  1. Ruby — System or managed?
  2. Init — rbenv in shell?
  3. 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:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

ArgumentError: missing keyword / unknown keyword — Ruby: ArgumentError: missing keyword: :name / unknown keyword: :nmae (Ruby / Rails)ArgumentError: missin…ArgumentError: wrong number of arguments (given 1, expected 2) — Ruby: ArgumentError: wrong number of arguments (given 1, expected 2..3) (Ruby / Rails)ArgumentError: wrong …avc: denied — SELinux is preventing ... / avc: denied { read } for pid=... (permission denied despite correct permissions) (Linux)avc: deniedBundler: Could not find gem in locally installed gems — Bundler: Could not find gem 'rails (~> 7.1)' in locally installed gems / Could not find rails-7.1.0 in any of the gem sources listed in your Gemfile (Ruby / Rails)Bundler: Could not fi…daemon — Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Docker)daemonDocker Desktop requires privileged access (vmnetd) — macOS: Docker Desktop needs privileged access / com.docker.vmnetd could not be started (macOS)Docker Desktop requir…EACCES — npm ERR! code EACCES — permission denied (npm)EACCESexec permission denied — exec /entrypoint.sh: permission denied (container won't start) (Docker)exec permission deniedYou don't…

Explore the map of this error Full error map →

🧠 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.