Member-only story

Fix: Failed to build gem native extension, cannot find ruby.h

More Less
1 min readDec 18, 2019

--

Under macOS Mojave 10.14.6, When I tried to do gem install jekyll locally, I met the following error:

mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

it is due to xcode has been upgraded, but the command line tool is not setting up correctly.

the solution is as following:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
sudo xcodebuild -license accept
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

after fixed that error, continune to build jekyll, it complains ruby version is too low.

ERROR: Error installing jekyll:
jekyll-sass-converter requires Ruby version >= 2.4.0.
~ moreless$ which ruby
/usr/bin/ruby
~ moreless$ brew upgrade ruby
Warning: ruby 2.6.5 already installed

therefore, reinstall ruby, and got following message:

$ brew reinstall ruby
==> Reinstalling ruby
==> Downloading https://homebrew.bintray.com/bottles/ruby-2.6.5.mojave.bottle.1.tar.gz
Already downloaded: /Users/yonwang/Library/Caches/Homebrew/downloads/182d59bf6e0c972f8d9271f628e7b87879c16b1954b0c886d286f83519c7e7b1 — ruby-2.6.5.mojave.bottle.1.tar.gz
==> Pouring ruby-2.6.5.mojave.bottle.1.tar.gz
==> Caveats
By default, binaries installed by gem will be placed into:
/usr/local/lib/ruby/gems/2.6.0/bin

--

--

More Less
More Less

Written by More Less

自由撰稿人,时评人,平等公义追求者

Responses (1)