jekyll: gem install jekyll failed on Mac OS X 10.11

$ gem install jekyll

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

Mac OS X 10.11 (15A282a) Xcode 7.0 (7A220)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 39 (18 by maintainers)

Most upvoted comments

Proposed Checklist for Mac OS X 10.11 El Capitan

  • Install the Xcode command line utilities xcode-select --install
  • Install Homebrew (instructions at http://brew.sh)
  • Modify $PATH to use Homebrew export PATH=/usr/local/bin:$PATH
  • Modify $PATH for GUI apps launchctl setenv PATH "/usr/local/bin:$PATH"
  • Install the latest Ruby brew install ruby
  • Install the latest Jekyll gem install jekyll

Note: Homebrew is designed to work without using sudo.

My sarcasm is used to illustrate that this issue should remain open.

This approach worked for me with OS X 10.11 15A282b. However, the other Mac advice at http://jekyllrb.com/docs/troubleshooting/#installation-problems did not work.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install ruby
gem install jekyll

This is contrast to Yosemite where I needed to use sudo:

sudo gem install jekyll

Since I no longer have a “stock” system, it would be helpful if someone else who just installed could validate this approach.

If the install instructions do not work on Mac, it should not be stated that this project supports Mac OS X.

Hi I got the same error as you did, likely because of macOS’s system integrity protection. This fixed it for me

  1. Install homebrew
  2. brew install ruby
  3. You will need to have ruby first in your PATH run echo ‘export PATH=“/usr/local/opt/ruby/bin:$PATH”’ >> ~/.bash_profile
  4. source ~/.bash_profile
  5. sudo gem install jekyll

I prefer…

$ gem install --user-install --bindir ~/bin --no-document --pre --verbose jekyll

Then… i.e…

  • $ ~/bin/jekyll new ~/Sites/testjekyll
  • $ ~/bin/jekyll serve --watch --verbose ~/Sites/testjekyll

And or add ~/bin to your $PATH shell variable to avoid requiring full path to jekyll.

Installing this way installs for and within the user account [only], instead of system-wide.

Have a few moments and want to reiterate, and re-share-- in a summary format, that installing jekyll (gems in general) by leveraging the gem executable capabilities to isolate ruby gem installations works out of box with OS X 10.11 for example with [only] the following, with the added benefit of leaving the system completely alone, and isolating jekyll and its dependencies to the current user/group [only]:

OS X XCode Command Line Utilities

Can be installed via calling a developer command such as git and following prompts.

With OS X’ native ruby and gem:

gem install --user-install --bindir ~/bin --no-document --pre --verbose jekyll

export PATH=$PATH:~/bin

$ jekyll --version
jekyll 3.0.0.pre.beta9

$ ruby --version
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
$ which ruby
/usr/bin/ruby

If System-wide meddling with a tinker-hostile environment is not your interest, and or you don’t want/need custom/specific Ruby environment(s) (rbenv, chruby, RVM, …), then a --user-install approach may be worth considering. And it works with stock OS X (10.11 currently).

I ended up using sudo gem install jekyll and it worked perfectly

Your comments help us none @fulldecent provide more information or refrain from commenting.

@jaybe-jekyll Brilliant, thanks.

Successfully installed jekyll-3.0.0.pre.beta8 17 gems installed

FYI, I think Apple has locked down the system directories in OS X 10.11, so the easy-install instructions on http://jekyllrb.com may need to change. Even using sudo won’t work.

@debbarmaonit The short answer to your question is that you can’t set usr/bin as the install location on 10.11 because SIP prevents it. There are instructions on Jekyll’s website for how to resolve this issue.

If however, you are familiar with either rbenv or RVM, you can instead create an isolated environment that doesn’t conflict with the system’s version of Ruby and then install with just gem install jekyll.

This worked for me (on Mojave):

  1. Install homebrew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Update ruby: brew install ruby

  3. Set ruby in your PATH: echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profile

  4. Install Jekyll into a folder that isn’t protected by SIP: sudo gem install -n /usr/local/bin/ jekyll

I am working on a PR to update those docs.