73

I am interested in installing one of the GitHub repos that requires installing CocoaPods. There is no problem with my terminal (seems fine in a normal macOS version). I have one problem though: terminal is not installing CocoaPods, seemingly because I'm on the macOS Catalina beta?

I did install the pod 'Card' from Podfile which finished but after that Podfile closes. I am going running "pod install" on the terminal, then the only error that I get is:

-bash: /usr/local/bin/pod: / 
System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory". 

Does someone know how to fix this issue for macOS Catalina?

James Cushing
  • 718
  • 1
  • 9
  • 18
Antonio Adrian Chavez
  • 1,016
  • 1
  • 7
  • 12
  • Ruby is present in Catalina, but I don't know what version it is, and in future versions it won't be present at all. You can use a ruby version manager and install 2.3 yourself if that's the issue. Also did you use `sudo`? It might help, I don't know. – matt Jun 13 '19 at 02:25

11 Answers11

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

worked for me

onthemoon
  • 3,302
  • 3
  • 17
  • 24
  • 1
    This did not worked for me, i have run to multiple answers on the web but i still have the same error:ERROR: Error installing cocoapods: invalid gem: package metadata is missing in /Library/Ruby/Gems/2.6.0/cache/httpclient-2.8.3.gem – Japa Nov 05 '19 at 11:49
  • 4
    Please make sure u di not forget this line: XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X – Raghav Chopra May 10 '20 at 08:49
  • this won't work until you have new Xcode 11. then it will work – luky May 20 '20 at 11:27
47

Use

brew install cocoapods --build-from-source

The Mojave bottle is linked to a different version of Ruby. The --build-from-source option will link the cocoapods gem to the Catalina version of Ruby.

I make my mark
  • 841
  • 6
  • 13
  • 15
    I had to follow this up with `brew link --overwrite cocoapods` – NSExceptional Dec 16 '19 at 21:35
  • 1
    Thanks! This answer + this comment saved my day. – mdonati Mar 31 '20 at 20:58
  • This was the only way to install cocoapods on Catalina for me. All other answers failed. Thanks a lot! – audience Apr 02 '20 at 10:50
  • 1
    fantastic, tried several commands to reconfigure the broken cocoapods. `brew install cocoapods --build-from-source` and `brew link --overwrite cocoapods` were the only ones that worked, thanks – Naishta Sep 11 '20 at 20:01
20

I also encountered this issue when I upgraded to Catalina and XCode 11. Here's what I did to fix this:

  1. Select Command Line Tools in XCode.

XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X

  1. In terminal execute:

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

superm0
  • 963
  • 11
  • 19
10

Try this to get cocopods works on macOS Catalina

$ brew cleanup -d -v    
$ brew install cocoapods
Atanu Mondal
  • 1,714
  • 1
  • 24
  • 30
5

I fixed it by installing cocoa pod again.

sudo gem install cocoapods -n /usr/local/bin
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
K Ravi Kumar
  • 71
  • 1
  • 2
5

I had not been able to solve use this one

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

Before this command I ran the following command and reinstalled cocoapod.

xcode-select --install

.

This worked for me

 xcode-select --install
 sudo gem install -n /usr/local/bin cocoapods
Park
  • 401
  • 4
  • 10
1

I had this problem with Catalina, to solve I have to made the following steps:

  1. Install XCode Command Line Tools, I recommend install the HomeBrew to solve that dependency: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Execute this command to reinstall cocoa pods: sudo gem install -n /usr/local/bin cocoapods

Ângelo Polotto
  • 8,463
  • 2
  • 36
  • 37
0
    [![If cannot install new version cocoapods, example below:
    1. Please remove Command line tools
    sudo rm -rf /Library/Developer/CommandLineTools
    2. Install new Command line tools version
    sudo xcode-select --install
    3. after installing run below command
    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg]

enter image description here

manishsharma93
  • 1,039
  • 1
  • 11
  • 26
siddhant
  • 39
  • 2
0

Check this one, worked for me

  1. Go to Xcode preferences -> Locations 'tab'.

  2. Check the Command Line Tools section. If it's blank, make sure your current command line tools is selected. XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X

  3. Run sudo gem install -n /usr/local/bin cocoapods

AzeTech
  • 623
  • 11
  • 21
0

So, issue is that in Mac OSX Catalina. The folder path /usr/local/bin is private.

So, Step 1: Install Homebrew. "Homebrew lets your access private folders and enables them to public".

Step 2: Restart Terminal or restart Mac OSX.

Step 3: Run sudo gem install cocoapods or sudo gem install -n /usr/local/bin cocoapods

Step 4: Let the setup complete

Step 5: Run pod setup

Finished :)

zhisme
  • 2,368
  • 2
  • 19
  • 28
0

Try to install cocoapods using brew

brew install cocoapods --build-from-source

if u have already installed cocoapods using brew it will not let you install cocoapods then try

brew link --overwrite cocoapods

then write

pod setup --verbose

hope it will work.