Software⏱️ 2 min read📅 2026-05-31

How to Fix: How to install a gem or update RubyGems if it fails with a permissions error

Install a gem or update RubyGems with permissions error solution.

Quick Answer: Run the command as an administrator or use sudo to gain write permissions.

Installing gems or updating RubyGems can be a frustrating experience when you encounter a permissions error. This issue typically arises due to the lack of write access to the system's gem directory.

✅ Best Solutions to Fix It

Method 1: Changing Permissions

  1. Step 1: Open the Terminal and navigate to the directory where RubyGems is installed, which is usually /usr/local/bin/ruby or /usr/bin/ruby.

Method 1: Changing Permissions (continued)

  1. Step 2: Run the command sudo chown -R root:staff /usr/local/lib/ruby/gems/2.0.0 to change the ownership of the gem directory.

Method 2: Using sudo

  1. Step 1: Run the command gem install mygem --install-location /usr/local/lib/ruby/gems/2.0.0 to install the gem in a specific location.

Method 3: Using sudo with RubyGems Update

  1. Step 1: Run the command sudo gem update --system --install-location /usr/local/lib/ruby/gems/2.0.0 to update RubyGems in a specific location.

🎯 Final Words

By implementing one of these methods, you should be able to resolve the permissions error and successfully install gems or update RubyGems.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions