I am trying to install CocoaPods on my Mac device. When I run the following command:

sudo gem install cocoapods

it returns:

Fetching: cocoapods-core-1.5.3.gem (100%)
Successfully installed cocoapods-core-1.5.3

ERROR:  Error installing cocoapods: invalid gem: package metadata is missing in /Library/Ruby/Gems/2.3.0/cache/cocoapods-deintegrate-1.0.2.gem

What is casing this issue and how do I install CocoaPods?

  • What is your question? What have you already tried to solve the problem? Can you install other gems without problems?
    – nohillside
    Aug 12, 2018 at 9:18
  • Not installed so far - @ nohillside
    – Bashirpour
    Aug 12, 2018 at 9:26

1 Answer 1


I'd recommend using Homebrew to install CocoaPods.

If you are not already using Homebrew, it is a package manager for macOS, hugely popular among developers of all types. It makes installing packages like CocoaPods hassle free.

To install Homebrew, follow the instructions on the homepage

Paste that at a Terminal prompt.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Homebrew requires Xcode Command Line Tools to be installed and setup (which I am assuming you already have as you are trying to install CocoaPods, implying you are developing for iOS).

Once Homebrew is setup, simply run:

brew install cocoapods

to install CocoaPods.

  • I was using sudo gem install cocoapods with sierra, got me errors... /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. went then to the logs and saying that :package configuration for libffi is not found. your solution worked for me. thanks !!
    – borei
    Mar 13, 2020 at 5:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .