Skip to main content
  1. About
  2. Stack Internal
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

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

I'm trying to install a gem using gem install mygem or update RubyGems using gem update --system, and it fails with this error:

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

Does anyone have an idea how to solve this?

Answer*

Reminder: Answers generated by AI tools are not allowed due to Stack Overflow's artificial intelligence policy

Draft saved
Draft discarded

Required fields are marked with *

Cancel
11
  • 4
    I don't know why your answer wasn't posted before. The --user-install option has apparently been around for a while. I just wish you had written this earlier. =)
    Michael come lately
    –  Michael come lately
    2016-08-19 14:01:50 +00:00
    Commented Aug 19, 2016 at 14:01
  • 8
    This needs to go to the top! Installing with sudo or su is a bad idea as you're enforcing a permissions system on the modules and possibly the globally installed packages could collide with otherwise installed packages or other projects' dependencies. Using rbenv requires you to install another software and adds a layer of complexity.
    Hugo G
    –  Hugo G
    2017-01-09 14:46:59 +00:00
    Commented Jan 9, 2017 at 14:46
  • 8
    This works, but warns: 'WARNING: You don't have /Users/<username>/.gem/ruby/2.0.0/bin in your PATH, gem executables will not run.' The following link provides useful instructions on how to update your path (without having to use vi) hathaway.cc/post/69201163472/…
    dawid
    –  dawid
    2017-01-12 06:18:47 +00:00
    Commented Jan 12, 2017 at 6:18
  • 4
    This is simple and logical. Add ruby path if you haven't in your bashrc if which ruby >/dev/null && which gem >/dev/null; then PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH" fi <br>Source:guides.rubygems.org/faqs/#user-install
    Inder Kumar Rathore
    –  Inder Kumar Rathore
    2017-08-22 10:42:13 +00:00
    Commented Aug 22, 2017 at 10:42
  • 1
    Can this screw up with Apple's (ruby installed) system?
    user5306470
    –  user5306470
    2018-05-24 17:42:32 +00:00
    Commented May 24, 2018 at 17:42

lang-rb
Morty Proxy This is a proxified and sanitized view of the page, visit original site.