taha
taha

Reputation: 33

CocoaPods not installed - ERROR: Failed to build gem native extension

Catalin 10.15.7, Xcode 12.3(12C33), flutter version 1.22.4 stable I repeatedly tried to install Cocoapods with sudo gem install cocoapods, but got an error failed to build gem native extension

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.5.1/ext/json/ext/generator
/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 ./siteconf20210115-11087-1nv1wqg.rb extconf.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.5.1/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.5.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
In file included from ./../fbuffer/fbuffer.h:5:
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 '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks')
1 error generated.
make: *** [generator.o] Error 1

make failed, exit code 2

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

also tried to used gem update , sudo gem uninstall cocoapods , sudo gem install cocoapods but not help me,tried rm -rf Pods/ Podfile.lock pod install can't run my project on the simulator

Upvotes: 0

Views: 993

Answers (2)

taha
taha

Reputation: 33

For my case, the following solution working great with me

if you don't remember cocoapods installing process was don by Gem Or brew,try both of 2 uninstalling option, to increase confirmation of uninstalling

sudo gem uninstall cocoapods
brew uninstall cocoapods

next step start install Cocoapods

brew install cocoapods --build-from-source
brew link --overwrite cocoapods
pod setup

You can also review the following links first link, second link

Upvotes: 2

Randal Schwartz
Randal Schwartz

Reputation: 44056

The built-in Ruby for Catalina is too old for cocoapods. I've had success by installing the ruby from brew, and either the cocoapods brew recipe, or the new ruby gem install. (Sometimes one works, sometimes the other works, never sure why.) Also requires some fidgeting to get PATH to put brew ruby ahead of the useless system ruby. Ugh.

Upvotes: 0

Related Questions