Fail to install Jekyll on MacOS


I try to install jekyll on MacOS 10.13.6 and get the following error. Anyone knows what is going wrong?

  • just updated Xcode and command-line tools
  • ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
  • Bundler version 1.16.4

$ gem install jekyll
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.5.0/gems/ffi-1.9.25/ext/ffi_c
/usr/local/opt/ruby/bin/ruby -r ./siteconf20180907-62376-f37vt3.rb extconf.rb
checking for ffi.h… no
checking for ffi.h in /usr/local/include,/usr/include/ffi… yes
checking for ffi_call() in -lffi… yes
checking for ffi_closure_alloc()… no
checking for ffi_raw_call()… no
checking for shlwapi.h… no
checking for ruby/thread.h… yes
checking for rb_thread_blocking_region()… no
checking for rb_thread_call_with_gvl()… yes
checking for rb_thread_call_without_gvl()… yes
creating extconf.h
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.5.0/gems/ffi-1.9.25/ext/ffi_c
make “DESTDIR=” clean
current directory: /usr/local/lib/ruby/gems/2.5.0/gems/ffi-1.9.25/ext/ffi_c
make “DESTDIR=”
Configuring libffi
configure: error: in /usr/local/lib/ruby/gems/2.5.0/gems/ffi-1.9.25/ext/ffi_c/libffi-x86_64-darwin17': configure: error: C++ preprocessor "/lib/cpp" fails sanity check Seeconfig.log’ for more details
make: *** ["/usr/local/lib/ruby/gems/2.5.0/gems/ffi-1.9.25/ext/ffi_c/libffi-x86_64-darwin17"/.libs/libffi_convenience.a] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/ffi-1.9.25 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0/ffi-1.9.25/gem_make.out


I’ve seen this on windows and it was cause I needed the Ruby devkit as well as ruby.

Try some of the solutiions in this SO post - it is not about Jekyll - but it is about a ruby gem and I think that is where the problem is (it is not a Jekyll issue).