Cocoapods: Build issue with Xcode 12.3 - file not found #include "ruby/config.h"

Created on 15 Dec 2020  路  29Comments  路  Source: CocoaPods/CocoaPods

Trying to install without using sudo with the following command.

gem install --user-install cocoapods

I saw a lot of errors and comments reported with Ruby on macOS with the same issue. Error generated is:

`package configuration for libffi is not found
"xcrun clang -o conftest -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/lib -arch x86_64 -lruby.2.6 "
In file included from conftest.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found

include "ruby/config.h"

     ^~~~~~~~~~~~~~~

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.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 '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks')
1 error generated.
checked program was:
/* begin /
1: #include "ruby.h"
2:
3: int main(int argc, char *
argv)
4: {
5: return 0;
6: }
/* end */`

I found that the build command used is:

xcrun clang -o conftest \ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19 \ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward \ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 \ -I. \ -D_XOPEN_SOURCE \ -D_DARWIN_C_SOURCE \ -D_DARWIN_UNLIMITED_SELECT \ -D_REENTRANT \ -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c \ -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib \ -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/lib \ -arch x86_64 \ -lruby.2.6

But, it needs to be

xcrun clang -o conftest \ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20 \ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward \ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 \ -I. \ -D_XOPEN_SOURCE \ -D_DARWIN_C_SOURCE \ -D_DARWIN_UNLIMITED_SELECT \ -D_REENTRANT \ -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c \ -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib \ -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib \ -arch x86_64 \ -lruby.2.6

Notice the following changes:

Instead of universal-darwin19, it is universal-darwin20
Instead of MacOSX10.15.Internal.sdk, it is MacOSX.sdk

awaiting input

Most helpful comment

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:

cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

All 29 comments

Seems to be an issue with macOS 10.15 and Xcode 12.
Combination of macOS 10.15 and Xcode 11 works fine.

Seems to be an issue with macOS 10.15 and Xcode 12.
Combination of macOS 10.15 and Xcode 11 works fine.

I just update rurby version to 2.7.2, resolve the problem

@wangjiajiajohn - How did you update the ruby? Can you please provide me the steps. I am stuck in this issue from 2 days. Thank you.

I am using Mac OS Catalina 10.15.7

Seems to be an issue with macOS 10.15 and Xcode 12.
Combination of macOS 10.15 and Xcode 11 works fine.

I just update rurby version to 2.7.2, resolve the problem

I didn't want to use brew or ports, so I had to downgrade Xcode to make it work.

Seems to be an issue with macOS 10.15 and Xcode 12.
Combination of macOS 10.15 and Xcode 11 works fine.

I just update rurby version to 2.7.2, resolve the problem

I didn't want to use brew or ports, so I had to downgrade Xcode to make it work.

Can confirm Command Line Tools 11.5 works on Catalina (10.15).

For those unfamiliar with changing/downgrading Command Line Tools:

  • Download Command Line Tools 11.5 from Apple Developer Downloads
  • sudo rm -rf /Library/Developer/CommandLineTools
  • Install Command Line Tools from .dmg/.pkg
  • sudo xcode-select --switch /Library/Developer/CommandLineTools
  • [sudo] gem install [--user-install] cocoapods
  • sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

This issue does not appear related to CocoaPod per se though right? It seems an environment issue?

This issue does not appear related to CocoaPod per se though right? It seems an environment issue?

I am concluding from my experience that it is not CocoaPods issue.

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:

cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:

cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

I just did a clean install of Catalina and the path above did not exist. The path I found it under is;

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0

The second part -

ln -s universal-darwin20 universal-darwin19

worked for me once I found the right directory.

I am having same problem with catalina 10.15.7, ruby 2.6.3p62!

Error:
did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks')
1 error generated.

Just update ruby to 2.7 and it will get resolved.

Just update ruby to 2.7 and it will get resolved.

how to upgrade ruby to 2.7...i had try too hard

https://rayhightower.com/blog/2013/05/16/upgrading-ruby-with-rvm/

Here is the instructions to update Ruby

but it is not for ruby-2.7 by rvm... because it tips "no binary rubies available 2.7.2"

I find someone meet same problem
https://ernestojeh.com/fix-jekyll-on-macos-big-sur

I solve it by:
"rvm use ruby-3.0"

https://www.jianshu.com/p/9c9f8d4867eb

https://rayhightower.com/blog/2013/05/16/upgrading-ruby-with-rvm/
Here is the instructions to update Ruby

but it is not for ruby-2.7 by rvm... because it tips "no binary rubies available 2.7.2"

Anyone else with this issue, this is what worked for me:

1) curl -sSL https://get.rvm.io | bash -s stable
2) close and reopen terminal
3) rvm install ruby@latest
4) rvm use ruby-3.0.0 --default

Anyone else with this issue, this is what worked for me:

  1. curl -sSL https://get.rvm.io | bash -s stable
  2. close and reopen terminal
  3. rvm install ruby@latest
  4. rvm use ruby-3.0.0 --default

Thank you!!
this worked for me

Just update ruby to 2.7 and it will get resolved.

This doesn't work for folks who use the Mac's default version of Ruby. It's a bad idea to replace Mac's system utilities-- instead, users would be better off installing Ruby from Homebrew or another source.

Solutions depending on your setup:

Anyone else with this issue, this is what worked for me:

  1. curl -sSL https://get.rvm.io | bash -s stable
  2. close and reopen terminal
  3. rvm install ruby@latest
  4. rvm use ruby-3.0.0 --default

ruby-2.7.2 will also work. So maybe ruby-2.6.0 cause the problem.

Can confirm Command Line Tools 11.5 works on Catalina (10.15).

For those unfamiliar with changing/downgrading Command Line Tools:

  • Download Command Line Tools 11.5 from Apple Developer Downloads
  • sudo rm -rf /Library/Developer/CommandLineTools
  • Install Command Line Tools from .dmg/.pkg
  • sudo xcode-select --switch /Library/Developer/CommandLineTools
  • [sudo] gem install [--user-install] cocoapods
  • sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Thank you!! This worked for me

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:

cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

Thanks!!!! This worked for me

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:

cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

Even with sudo I get the following 'ln: universal-darwin19: Permission denied'. How can I fix this?

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:
cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

Even with sudo I get the following 'ln: universal-darwin19: Permission denied'. How can I fix this?

Fixed it by running with sudo and the -f option instead at path: sudo ln -sf universal-darwin20 universal-darwin19

Seems to be an issue with macOS 10.15 and Xcode 12.
Combination of macOS 10.15 and Xcode 11 works fine.

I just update rurby version to 2.7.2, resolve the problem

Oh,.. you save me.. very thks.......!!!!!!

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:
cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

Even with sudo I get the following 'ln: universal-darwin19: Permission denied'. How can I fix this?

Fixed it by running with sudo and the -f option instead at path: sudo ln -sf universal-darwin20 universal-darwin19

This solved the issue for me.

Trying to install without using sudo with the following command.

gem install --user-install cocoapods

Hey Oransel, running gem install --user-install cocoapods like you suggested worked for me! I am on Mac Big Sur 11.2.1, Xcode 12.4, ruby 2.6.3p62,

I just updated to Xcode 12.3 and I am hitting this issue. Seems like Xcode 12.3 broke the system ruby installation. This solved it for me:

cd $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 && ln -s universal-darwin20 universal-darwin19

Thanks!!! This works for me!!

Was this page helpful?
0 / 5 - 0 ratings