# macOS: ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory

**Code:** `You don't have write permissions for the /Library/Ruby/Gems directory` · **Category:** macOS · **Seen on:** macOS, Ruby

`gem install` tries to write into Apple's system Ruby, which is protected and shouldn't be modified.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/macos/bundle-install-no-write-permissions-system-ruby)
