How to fully uninstall the Cocoapods from the Mac Machine?

50

30

I installed Cocoapods version 0.28, and now I want to uninstall it from my machine. How can I do that?

user3004499

Posted 2013-12-10T06:28:06.243

Reputation: 601

Answers

84

First, determine which version(s) of Cocoapods you have installed by running this in Terminal:

gem list --local | grep cocoapods

You see output similar to this:

cocoapods (0.27.1, 0.20.2)
cocoapods-core (0.27.1, 0.20.2)
cocoapods-downloader (0.2.0, 0.1.2)

Here, I have two versions of Cocoapods installed.

To completely remove, issue the following commands:

gem uninstall cocoapods
gem uninstall cocoapods-core
gem uninstall cocoapods-downloader

If you have multiple versions installed, like I have, it will prompt you to choice a specific version or all. If you want to uninstall a specific version you can also use the -v switch as follows:

gem uninstall cocoapods -v 0.20.2

Running gem list --local | grep cocoapods again will confirm that Cocoapods has been removed.

You may have residual artefacts in a hidden folder in your home directory. Remove these with:

rm -rf ~/.cocoapods

neilco

Posted 2013-12-10T06:28:06.243

Reputation: 949

1add sudo before every command if it gives error like "You don't have write permissions for the /usr/bin directory". For e-g sudo gem uninstall cocoapods – Nasir Mahmood – 2014-12-11T10:18:25.820

3You may also want to remove the files cocoapods creates with: rm -rf ~/.cocoapods – Adam – 2015-03-20T20:22:15.220

Thanks sir. However mine were in a Ruby folder so Terminal hinted: try this command instead: 'gem uninstall -i /Users/Rob/.rvm/gems/ruby-2.3.1@global cocoapods' – Rob – 2016-10-16T08:23:49.390

gem list doesn't list cocoa pods as installed on my Mac, yet there is a large hidden cocoapods directory in my home directory. How to continue from there? where should I look for cocoapods leftovers? I cannot rely on gem here. – Motti Shneor – 2019-10-07T04:08:28.480

@MottiShneor From two comments above your's: rm -rf ~/.cocoapods. – neilco – 2019-10-08T10:29:50.043

30

I used the following bash script to remove all the relevant gems.

for i in $( gem list --local --no-version | grep cocoapods );
do 
    gem uninstall $i; 
done

Additionally delete ~/.cocoapods to remove the cache of podspecs.

rm -rf ~/.cocoapods/

Ayush Goel

Posted 2013-12-10T06:28:06.243

Reputation: 401

This is the complete answer – William Entriken – 2016-02-13T18:05:24.137

9this is same and better: gem list --local --no-version | grep cocoapods | xargs gem uninstall – Eir Nym – 2016-04-24T13:50:03.730

I need sudo for do gem uninstall, so I modified the bash like this (one line command):

for i in $( gem list --local --no-version | grep cocoapods ); do sudo gem uninstall $i; done – Daniele – 2019-09-10T15:53:52.330

9

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

AmitP

Posted 2013-12-10T06:28:06.243

Reputation: 191

This is the only one that worked for me, thanks! Together with sudo rm -fr ~/.cocoapods/repos/master it finally removed everything. – turingtested – 2018-10-10T13:27:08.023

8

Easy, just run the following command to remove all or just a specific cocoapod gem:

sudo gem uninstall cocoapods

NSMutableString

Posted 2013-12-10T06:28:06.243

Reputation:

1

I was following this answer but for Mac OS X El Capitan 10.11 I was encountering an error as below on executing gem uninstall -n cocoapods command

pranav-MacBook-Pro:~ pranavpranav$ gem uninstall -n cocoapods
ERROR:  While executing gem ... (Gem::CommandLineError)
    Please specify at least one gem name (e.g. gem build GEMNAME)

In order to overcome the issue with permissions you must use the below command

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

Pranav Jaiswal

Posted 2013-12-10T06:28:06.243

Reputation: 111

this works for me, thanks – James Yang – 2019-09-29T05:23:59.730

1

This is what perfectly work for me.

  1. Uninstall CocoaPods (choose to uninstall all versions):

    sudo gem uninstall cocoapods

  2. Remove old master repo:

    sudo rm -fr ~/.cocoapods/repos/master

BatyrCan

Posted 2013-12-10T06:28:06.243

Reputation: 111

1This would be less confusing if you included only the information necessary to uninstall. Adding the bits about reinstallation doesn't make sense as part of an answer to this question. – music2myear – 2017-03-17T22:12:22.257

thanx, i will do it next time. – BatyrCan – 2017-03-23T07:53:18.090

0

Remove lib form Podfile, then pod install again.

Imran Ali Khan

Posted 2013-12-10T06:28:06.243

Reputation: 101