'Permission Denied' at 'require rubygems

chombee's Avatar


12 Aug, 2011 06:55 PM

Can anyone help me fix this problem with my ruby gems on OS X? I've installed jekyll, but when I run the jekyll command I get a Permission Denied error:

$ jekyll
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:89:in `read': Permission denied - /Library/Ruby/Gems/1.8/specifications/rubygems-update-1.8.3.gemspec (Errno::EACCES)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:89:in `load_specification'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:153:in `load_gems_in'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:152:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:152:in `load_gems_in'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:149:in `reverse_each'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:149:in `load_gems_in'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:345:in `refresh!'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:78:in `from_gems_in'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/source_index.rb:58:in `from_installed_gems'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:881:in `source_index'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/gem_path_searcher.rb:13:in `initialize'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:839:in `new'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:839:in `searcher'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:838:in `synchronize'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:838:in `searcher'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:478:in `find_files'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1103
from /usr/bin/jekyll:9:in `require'
from /usr/bin/jekyll:9

If I run sudo jekyll it works fine. Somewhere some files have the wrong permissions. /usr/bin/jekyll:9 is require 'rubygems'. I think this problem might have been caused by running sudo gem ... commands with a 077 umask. Any suggestions for how I can go about fixing this?


  1. 1 Posted by chombee on 18 Aug, 2011 08:47 AM

    chombee's Avatar

    I'm actually getting this permission denied error whenever I run any gem command (even just gem). I've tried doing umask 022 and then sudo gem update --system, tried downloading RubyGems and reinstalling it with sudo ruby setup.rb, neither helped. I'm stumped.

  2. 2 Posted by chombee on 18 Aug, 2011 10:50 AM

    chombee's Avatar

    I managed to get around this by installing rubygems from macports and setting my $PATH to use the version from macports instead of the other rubygems. Not sure if the macports rubygems and the other rubygems (which I can't even remember where it came from) install gems into the same location, but I used the gem command to uninstall all gems and then reinstall them with the right umask. Jekyll is running without sudo for now.

  3. 3 Posted by Gabriel Horner on 25 Aug, 2011 03:34 AM

    Gabriel Horner's Avatar

    Is this still an issue? For future reference, please install rubygems in a location that doesn't require sudo.

  4. 4 Posted by chombee on 26 Aug, 2011 07:17 PM

    chombee's Avatar

    I got around it by installing rubygems using macports and setting my path to use the macports copy. I then used it to uninstall all gems and then reinstalled them this time using the correct umask. I guess I still have the broken rubygems install but I just avoid it. The rubygems install page doesn't say anything about installing in your home dir (in fact it says to install using sudo). Won't ruby setup.rb try to install system-wide?

  5. Support Staff 5 Posted by Eric Hodel on 26 Aug, 2011 09:33 PM

    Eric Hodel's Avatar

    If you reinstall RubyGems using sudo and a sane umask (like 0022) it will work fine. You will need to reinstall your gems with a sane umask too. The easy way to do this would be to remove /Library/Ruby/Gems/1.8/*.

    RubyGems is usually installed in the same directories as your Ruby install. You can install RubyGems in a separate path using --prefix but you must then set RUBYOPT or use ruby -I. I don't recommend this.

  6. Eric Hodel closed this discussion on 26 Aug, 2011 09:33 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac