Phong Yew Tong
2 min readJan 2, 2022

--

Flutter: did not find header ‘config.h’ in framework ‘ruby’ when running sudo gem install cocoapods on big sur macOS.

macos big sur cocoapods

While setting up flutter and installing cocoapods on mac os, you might run into this error on Big Sur macOS in this log file:

/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.12.2/mkmf.log

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header ‘config.h’ in framework ‘ruby’ (loaded from ‘/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks’)
1 error generated.

Full error on console

MacBook-Pro-2:app phongyewtong$ sudo gem install cocoapods
Ignoring ffi-1.12.2 because its extensions are not built. Try: gem pristine ffi — version 1.12.2
Fetching tzinfo-2.0.4.gem
Fetching zeitwerk-2.5.3.gem
Fetching activesupport-6.1.4.4.gem
Fetching i18n-1.8.11.gem
Fetching addressable-2.8.0.gem
Fetching public_suffix-4.0.6.gem
Fetching cocoapods-core-1.11.2.gem
Fetching cocoapods-downloader-1.5.1.gem
Fetching molinillo-0.8.0.gem
Fetching nanaimo-0.3.0.gem
Fetching rexml-3.2.5.gem
Fetching xcodeproj-1.21.0.gem
Fetching cocoapods-1.11.2.gem
Successfully installed i18n-1.8.11
Successfully installed tzinfo-2.0.4
Successfully installed zeitwerk-2.5.3
Successfully installed activesupport-6.1.4.4
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20220102–30321–14trs7r.rb extconf.rb
checking for ffi.h… /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do’: The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for’
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header’
from extconf.rb:10:in `system_libffi_usable?’
from extconf.rb:34:in `<main>’

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.12.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.12.2/gem_make.out

Solution: Update your ruby version 2 to the latest

Install rvm

curl -L https://get.rvm.io | bash -s stable

Run script

source /Users/phongyewtong/.rvm/scripts/rvm

Install the latest ruby

rvm install ruby --latest

or install 3.1.0 (latest at the point of writing)

rvm install ruby 3.1.0

Use default

rvm --default use 3.1.0

then run again. Hurray!

sudo gem install cocoapods

Drop me some claps if this article helps you, it motivates me to create more! Thanks! 👏👏👏

--

--

Phong Yew Tong

I will follow you back. Entrepreneurship, React, Flutter, Firebase, Typescript, Javascript, ChatGPT, Crypto. Visit www.aiwithwords.com