333

I am trying to install cocoapods to my MacBook Pro running with OSX 10.9.1 (new Mavericks) and after type gem install cocoapods I get the following error:

    Building native extensions.  This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

        "/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby" -rubygems /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.1.1/bin/rake RUBYARCHDIR=/Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext RUBYLIBDIR=/Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext
/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for -std=c99 option to compiler... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `block in try_compile'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:443:in `with_werror'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `try_compile'
    from extconf.rb:24:in `block in <main>'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from extconf.rb:23:in `<main>'
rake aborted!
Command failed with status (1): [/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/...]

Tasks: TOP => default => ext
(See full trace by running task with --trace)


Gem files will remain installed in /Users/rangreenberg/gems/gems/xcodeproj-0.14.1 for inspection.
Results logged to /Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext/xcodeproj/gem_make.out
1
  • Try to switch ruby to homebrew version. brew install ruby brew link --overwrite ruby If you need to have ruby first in your PATH run: echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile For compilers to find ruby you may need to set: export LDFLAGS="-L/usr/local/opt/ruby/lib" export CPPFLAGS="-I/usr/local/opt/ruby/include" For pkg-config to find ruby you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig" Commented Nov 9, 2021 at 12:26

40 Answers 40

1
2
0

I had multiple environments in my configuration, which was causing problems as rvm was interfering with the installation. Once ruby 2.x was detected the install went fine.

For my environment I did the following: 1. xcode-select --install 2. rvm implode (Note - too drastic - you may not need to do this, I didn't have any use for the older ruby installations, I removed them via rvm uninstall one-by-one and then used rvm implode 3. gem install cocoapods

This time the last command worked without any issues.

Sign up to request clarification or add additional context in comments.

Comments

0

You must use the command in Terminal for installing Command Line Tools:

xcode-select --install

If you receive the message as a result of "Can't install the software because it is not currently available from the Software Update server.", You must download manually Command Line Tools from Apple site.

Comments

0

The same initial issue occurred when attempting to setup GoogleMaps in a Flutter app after running pod install on the iOS directory.

Running pod install the following error appeared:

zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory

Next, after running sudo gem install cocoapods that resulted in another error similar to that shown at ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension.

ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

kevin recommends installing Xcode Developer Tools running:

xcode-select --install

and while highlighting the need to install the tools, the system again produced the same error as before when running the pod install command.

Refresing the tools by removing and reinstalling them became the next target. The tools are removed with the following command:

rm -rf /Library/Developer/CommandLineTools

And again installing the xcode developer tools using:

xcode-select --install

Then, sudo gem install cocoapods and pod install ran successfully.

Comments

0

None of previous solutions worked for me...

My situation is a fresh clean install of macOS Catalina + XCODE;

It happen that I had to first run Xcode before install cocoa pods (in first run, Xcode setups machine with tools);

After that, cocoa pods worked fine.

Comments

0

This should unshallow both the cask and the core repo.

brew tap homebrew/cask

followed by...

brew tap homebrew/core

Comments

0

I have same issue, cocoapods was not installing and waste 3 to 4 hours to get solve this error and finally I got the solution,

step1: open the terminal and run "brew reinstall ruby" and terminal will guide you how to export the path step2: and then run "sudo gem install cocoapods"

Comments

0

The problem is outside Unity. You need to run the terminal and enter this commands:

sudo gem install -n /usr/local/bin cocoapods
pod setup

This saved my day !

Comments

0

Mac Monterey 12.5, follow these steps work for me

1. sudo xcode-select --install
2. sudo xcode-select --reset

Comments

0

Same error for me, due to old version ruby:

 ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

Follow worked for me (macOS 11.5.2 Big Sur):

  1. install GPG key
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
  1. install nvm (and using nvm install new version ruby)
curl -sSL https://get.rvm.io | bash -s stable --ruby

here installed version:

 nvm --version
0.30.1

 ruby --version
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]

 which ruby
/Users/crifan/.rvm/rubies/ruby-3.0.0/bin/ruby

 gem --version
3.2.3
  1. use gem to install cocoapods
sudo gem install cocoapods

installed version:

 which pod
/Users/crifan/.rvm/rubies/ruby-3.0.0/bin/pod
 pod --version
1.11.3

  • Note

using homebrew install cocoapods

brew install cocoapods

is ok for me, but the version is relative old:

~  pod --version
1.10.1

and here for development need latest version cocoapods, so need using gem to install the latest cocoadpods.

Comments

-1

1.Update Brew

brew update

2.Install Cocoapods

brew install cocoapods

Comments

1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.