Fix Ruby Gems Permission Error

The Problem

When install gem in Mac OS X Yosemite, I got the following error:

ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

The Solution

Step 1: Install Rbenv

brew install rbenv ruby-build

echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”’ >> ~/.zshrc

echo ‘eval “$(rbenv init -)”’ >> ~/.zshrc

Note: Modify your ~/.bash_profile instead of ~/.zshrc file if you’re not using zsh.

Step 2: Close your terminal and restart the shell

Step 3: Install Ruby, Set globle and Rehash

rbenv install 2.0.0-p247

rbenv global 2.0.0-p247

rbenv rehash

Step 4: gem install as usual

Now you should get the gem successfully installed!

Originally published at on May 29, 2015.

By Victor Leung

Experience in software development, consulting services and technical product management. Understanding of business and technology with an MBA in Finance and a Master degree in Computer Science. AWS Certified Solution Architect with experience in building products from scratch and serving as a charismatic leader.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: