genghiskhan
genghiskhan

Reputation: 1149

MacOS Cannot Install Jekyll Gem

I have tried everything to try to install the jekyll gem. I uninstalled/reinstalled rbenv, installed ruby 2.6.1, set it as global, run xcode-select --install about 1000 times, run xcode-select --switch /Library/Developer/CommandLineTools, and gem update --system among various other stack overflow fixes. None of which have worked. Every time, I get this familiar error message:

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

    current directory: /usr/local/lib/ruby/gems/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
/usr/local/opt/ruby/bin/ruby -I 
/usr/local/Cellar/ruby/2.6.1/lib/ruby/2.6.0 -r ./siteconf20190302-90413-16ok71q.rb extconf.rb
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR="
compiling ruby_http_parser.c
In file included from ruby_http_parser.c:1:
In file included from /usr/local/Cellar/ruby/2.6.1/include/ruby-2.6.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.6.1/include/ruby-2.6.0/ruby/ruby.h:29:
/usr/local/Cellar/ruby/2.6.1/include/ruby-2.6.0/ruby/defines.h:123:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make: *** [ruby_http_parser.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.6.0/gems/http_parser.rb-0.6.0 for inspection.
Results logged to 
/usr/local/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/http_parser.rb-0.6.0/gem_make.out

EDIT:

I am using MacOS 10.14 and this is my gem environment:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.2
  - RUBY VERSION: 2.6.1 (2019-01-30 patchlevel 33) [x86_64-darwin18]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.6.0
  - USER INSTALLATION DIRECTORY: /Users/<username>/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.6.0/bin
  - SPEC CACHE DIRECTORY: /Users/<username>/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: 
    /usr/local/Cellar/ruby/2.6.1/etc
  - RUBYGEMS PLATFORMS:
        - ruby
        - x86_64-darwin-18
  - GEM PATHS:
        - /usr/local/lib/ruby/gems/2.6.0
        - /Users/<username>/.gem/ruby/2.6.0
        - /usr/local/Cellar/ruby/2.6.1/lib/ruby/gems/2.6.0
  - GEM CONFIGURATION:
        - :update_sources => true
        - :verbose => true
        - :backtrace => false
        - :bulk_threshold => 1000
  - REMOTE SOURCES:
        - https://rubygems.org/
  - SHELL PATH:
        - /usr/local/opt/ruby/bin
        - /bin
        - /Users/<username>/.rbenv/shims
        - /Users/<username>/.rbenv/bin
        - /Library/Frameworks/Python.framework/Versions/3.6/bin
        - /usr/local/bin
        - /usr/bin
        - /bin
        - /usr/sbin
        - /sbin
        - /opt/X11/bin
        - /usr/local/share/dotnet
        - /usr/local/go/bin
        - /Users/<username>/.rbenv/bin
        - /Users/<username>/.rbenv/shims
        - /Users/<username>/.rbenv/shims
        - /Users/<username>/.rbenv/bin
        - /Library/Frameworks/Python.framework/Versions/3.6/bin
        - /usr/local/bin
        - /usr/bin
        - /bin
        - /usr/sbin
        - /sbin
        - /usr/local/go/bin
        - /usr/local/share/dotnet
        - /opt/X11/bin
        - /Users/<username>/.rbenv/bin
        - /Users/<username>/.rbenv/shims
        - /bin

Not sure why I have so many duplicates in my $PATH but probably because of my bash_profile.

Upvotes: 3

Views: 2033

Answers (1)

lacostenycoder
lacostenycoder

Reputation: 11186

It looks like your PATH setup is loading system ruby and not your rbenv ruby.

Try to remove this line from your .bash_profile since you don't want to use system ruby but the version from RBENV.

/usr/local/opt/ruby/bin

If that doesn't work, I'm not sure why you have so duplicates in your path, perhaps from multiple attempts to use RBENV.

I would suggest first, to reinstall RBENV. You'll first need to uninstall RBENV by doing the following:

grep rbenv ~/.bashrc ~/.bash_profile ~/.zshrc /etc/profile /etc/profile.d/*

Remove any lines related to RBENV in files which may have them.

Remove rbenv

rm -rf ~/.rbenv 

If you used homebrew to install rbenv, then

brew uninstall rbenv

Then brew doctor and see if there's anything else of concern reported.

Close all running terminals, then open a new one. Then check gem env again and you should see a cleaner state with nothing related to RBENV only your system ruby.

Or if you prefer, you might try RVM first instead, to do that see https://rvm.io/rvm/install

You might need to restart terminal after that, then go to your middleman project folder and run

bundle install

Upvotes: 3

Related Questions