cocoapods not installing

Using following commands, it worked for me.

  1. sudo gem uninstall cocoapods
  2. sudo gem install -n /usr/local/bin
  3. cocoapods pod install

If you encounter this error on step 2:

ERROR: While executing gem ... (Gem::CommandLineError) Please specify at least one gem name (e.g. gem build GEMNAME)

Then try this as step 2 instead (step 3 is not needed):

gem install -n /usr/local/bin cocoapods

If you install cocoapod using brew like me

  1. Reinstall cocoapods:

    brew reinstall cocoapods
    

If you see this error message after you reinstall cocoapods by brew reinstall go to step 2.

>
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
  rm '/usr/local/bin/pod'

To force the link and overwrite all conflicting files:
  brew link --overwrite cocoapods

To list all files that would be deleted:
  brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj
  1. To solve conflicting files:

    brew link --overwrite cocoapods
    

    Linking /usr/local/Cellar/cocoapods/1.3.1... 2 symlinks created


Uninstall the existing cocoapods, if any, by following command:

gem list --local | grep cocoapods | awk '{print $1}' | xargs sudo gem uninstall

Then install it to /usr/local/bin instead of /usr/bin using following command:

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

For further query, check this link to uninstall and this link to install cocoapods.