Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gem install jekyll failed on Mac OS X 10.11 #3984

Closed
ghost opened this issue Sep 21, 2015 · 38 comments

Comments

Projects
None yet
@ghost
Copy link

commented Sep 21, 2015

$ 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)

@jaybe-jekyll

This comment has been minimized.

Copy link
Member

commented Sep 21, 2015

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.

@envygeeks

This comment has been minimized.

Copy link
Contributor

commented Sep 21, 2015

This is not a Jekyll bug, please ask your question at https://talk.jekyllrb.com as this medium is for bugs.

@envygeeks envygeeks closed this Sep 21, 2015

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 21, 2015

@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.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 21, 2015

@envygeeks Is there a process for reporting documentation bugs?

@envygeeks

This comment has been minimized.

Copy link
Contributor

commented Sep 21, 2015

What do you think is a bug @chmaynard?

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 21, 2015

The easy-install instructions for jekyll don't seem to work in OS X 10.11 (El Capitan). Apple plans to release this new version of OS X in a few weeks, so you folks might want to investigate.

@envygeeks

This comment has been minimized.

Copy link
Contributor

commented Sep 21, 2015

If you are using RVM or Rbenv to do the install ( -- they installed ruby and rubygems -- ) via non-root userland you'll need to file a bug with them, if you are using system Ruby, it never worked the way you expected it to because you need to sudo to do system installs. If it did work before that then that is a glaring security bug for OS X.

@envygeeks

This comment has been minimized.

Copy link
Contributor

commented Sep 21, 2015

We also hint at t he need to sudo in the troubleshooting: http://jekyllrb.com/docs/troubleshooting/#installation-problems it could use a reworking though and if I recall somebody submitted or is going to submit the changes.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 21, 2015

@envygeeks I know almost nothing about Ruby, so please excuse my ignorance. It sounds like I must have used "sudo gem install" at some point in the past. I'm now wondering what will happen when the average user tries to install jekyll on a clean copy of OS X 10.11. Maybe I'll try that myself.

@fulldecent

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2015

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

@envygeeks

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2015

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

@fulldecent

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2015

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.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 22, 2015

@fulldecent Thanks for your advice. I hadn't thought about using Homebrew to install Ruby. That makes perfect sense because Homebrew will install Ruby into /usr/local instead of /Library/Ruby, which may be off-limits if Apple SIP is enabled.

@ghost ghost changed the title "gem install jekyll" failed on Mac OS X 10.11 gem install jekyll failed on Mac OS X 10.11 Sep 22, 2015

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 22, 2015

Summary

The installation problem occurs because OS X ships with a copy of Ruby in /Library/Ruby, a directory which is owned and controlled by the OS. In past versions of OS X, a new jekyll user could use sudo gem install jekyll to install software into this directory. That may not be possible in OS X 10.11, because Apple is now using System Integrity Protection (SIP) to further restrict write access to some system directories.

@fulldecent found a good work-around for 10.11:

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

A drawback with this work-around is that the user needs to install Homebrew and Ruby before installing jekyll. The user may also need to update their $PATH variable to give /usr/local/bin precedence over /usr/bin.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 22, 2015

It would be helpful to re-open this issue to give it more visibility.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 23, 2015

I just tried the work-around described above and it worked flawlessly.

@fulldecent

This comment has been minimized.

Copy link
Contributor

commented Sep 23, 2015

@chmaynard Thanks for your help. Is your system a stock upgrade or install? And have you installed Xcode command line tools before doing this?

I just want to track all the factors here.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 24, 2015

@fulldecent I previously installed both Xcode and Homebrew. We probably need to refine your install procedure for people who are not developers. See below.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 25, 2015

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.

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 25, 2015

Please add the "Documentation" label to this issue.

@chrisfinazzo

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2015

@envygeeks, I'm almost certain I have a branch where I was working on this at some point, will take another look...

@chmaynard, In the past, I can recall discussions with the Core team regarding how the installation of Ruby should be handled. While installing in the manner you suggest does solve the problem of putting Jekyll's Ruby in an isolated environment, I have had fewer gem conflicts when using a version that is slightly older than what Homebrew will give you. To facilitate that, might I suggest pointing to any of the various Ruby managers out there and people can choose which one suits their needs. Not as an outright requirement, but perhaps an "Information" block here.

This probably will go away as 3.0 makes many things "opt-in", but it's still something to consider.

Lastly, to provide a definitive answer regarding SIP and available directories, the following information is directly from Session 706. The only change since then is (I think) Applications/Utilities, but as I am not running the GM build, I cannot verify this. As it has been disclosed elsewhere and El Capitan is scheduled to ship next week, this is likely considered public knowledge.

screen shot 2015-09-23 at 10 24 27 am

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 25, 2015

@chrisfinazzo Thanks for the info about SIP. I wasn't sure about /Libary, so that's good news. Apple is advising developers to stop using /Library for kernel extensions, so I assumed that applied across the board.

I still think that Homebrew is a good option for two reasons: sudo isn't required, and it doesn't disturb Apple's native Ruby software in /Library/Ruby.

I believe Homebrew can install previous versions of Ruby. What version would be best for Jekyll?

@ghost

This comment has been minimized.

Copy link
Author

commented Sep 25, 2015

To facilitate that, might I suggest pointing to any of the various Ruby managers out there and people can choose which one suits their needs.

These are package managers for Ruby?

@parkr

This comment has been minimized.

Copy link
Member

commented Sep 25, 2015

@chmaynard RVM, rbenv, chruby, etc.

@jaybe-jekyll

This comment has been minimized.

Copy link
Member

commented Sep 25, 2015

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).

@chrisfinazzo

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2015

@chmaynard, My rule of thumb has been to follow the base version in .travis.yml, and thus far, I've had no issues that I couldn't figure out. The versions there have been tested and we know they work.

@jaybe-jekyll Are you sure? I would be concerned that when 10.11.1 comes out (which might be sooner rather than later), the Installer either does chown to whatever it finds in this directory or blows away the contents entirely.

The message from Apple seems to be pretty clear: If you have things that you compile yourself, put them in usr/local under the appropriate subdirectory. Otherwise, proceed at your own risk.

@jaybe-jekyll

This comment has been minimized.

Copy link
Member

commented Sep 25, 2015

@chrisfinazzo I am sure.

My agreement with Apple does not permit me to openly discuss details of beta or GM releases.

However, I can state the information and experience I provided was performed within such an environment.

Regarding "the installer" performing chown, and concerns about how it works, see the documentation for gem and you'll find corresponding information about each switch and option.

This approach, summarized, can be described as:

"Using OS X 10.10+ system ruby and gem, and without requiring homebrew, kindly install jekyll (pre-release version even!) with gem and tell gem to install it as and for my/this/current user [only], within the user' ~ ($HOME), and place binaries in users ~/bin. Thanks! (Oh- and leave OS X system alone!) :)

The point from Apple describes, precisely, my earlier reference to...

Tinkle-hostile environment.

I believe Apple is referring to meddling within System affairs. Performing operations in ones ~ ($HOME) is sanitary and expected.

@envygeeks

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2015

Most people's home directories look like a garbage dump.

@chrisfinazzo

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2015

See #3999.

@chrisfinazzo

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2016

@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.

@charlesfayal

This comment has been minimized.

Copy link

commented May 27, 2016

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

@aaroncampbell2311

This comment has been minimized.

Copy link

commented Jun 20, 2016

I'm using Mac El Capitan version 10.11.5 and sudo gem install jekyll worked just fine.

@ghost

This comment has been minimized.

Copy link
Author

commented Nov 25, 2018

I'm also running into this issue on current macOS Mojave.

$ sudo gem install jekyll
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20181125-42813-1vdjstq.rb extconf.rb
creating Makefile

current directory: /Library/Ruby/Gems/2.3.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.3.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR="
make: *** No rule to make target `/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18/ruby/config.h', needed by `ruby_http_parser.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/http_parser.rb-0.6.0 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/http_parser.rb-0.6.0/gem_make.out

I've recently installed ruby and rbenv successfully using brew, but the error is still there.

@TheTechAngle

This comment has been minimized.

Copy link

commented Dec 5, 2018

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
@matthieuviglietti

This comment has been minimized.

Copy link

commented Feb 1, 2019

On Mojave, you can also desactivate temporarly SIP MAC protection, by restarting in recovery mode and use terminal with
csrutil disable; reboot

to re-eanble it csrutil enable; reboot

@liamrosenfeld

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2019

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.

@MalayaliRobz

This comment has been minimized.

Copy link

commented Apr 13, 2019

what worked for me was:
open /Library/Developer/CommandLineTools/Packages/

Run the package macOS_SDK_headers_for_macOS_10.14.pkg

@coooliang

This comment has been minimized.

Copy link

commented Apr 20, 2019

sudo gem install -n /usr/local/bin jekyll bundler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.