Snowcrash
Snowcrash

Reputation: 86317

pod install -bash: pod: command not found

I installed pod some time ago. However, it's stopped working so I'm working through this again.

However, I almost immediately run into a problem here:

pod install
-bash: pod: command not found

Any suggestions why this happened?

Upvotes: 411

Views: 675234

Answers (30)

Wajid Ali
Wajid Ali

Reputation: 91

For Mac(M1) users:

Install cocoapods using brew instead of gem.

brew install cocoapods

and then

cd ios && pod install

Upvotes: 7

Abdur Rehman
Abdur Rehman

Reputation: 555

I tried all the above, but this worked for me, and if you are using the latest Xcode this will also work for you:

sudo gem install cocoapods

Got Error:

In Case sudo gem install cocoapods is not working for you, then you can follow these steps.

Error installing cocoapods:
The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6.
drb requires Ruby version >= 2.7.0. The current ruby version is 
 2.6.10.210.

Then Try installing it with sudo gem install drb -v 2.0.6 and then running the current command again.

Again Erro After running the above commands if you get the error again! saying that:

 Error installing cocoapods:
The last version of activesupport (>= 5.0, < 8) to support your Ruby & 
RubyGems was 6.1.7.7.

Try installing it with sudo gem install activesupport -v 6.1.7.7 and then running the current command again

sudo gem install activesupport -v 6.1.7.7

sudo gem install cocoapods

Now it will work for you. Happy Coding

I hope this will work for you.

Upvotes: 5

Niyati
Niyati

Reputation: 1

When I am installing cocoapod in terminal I got successfully install message but when I did init pod I got message that pod not found so I tried this.

export PATH="/Users/macOS_account_(username)/.gem/ruby/2.6.0/bin:$PATH"
gem install cocoapods --user-install

Example: My username is niyati in my macOS so I am useing like this.

export PATH="/Users/niyati/.gem/ruby/2.6.0/bin:$PATH"
gem install cocoapods --user-install

It is usefull for me I hope it will usefull to all!!

Thank you!

Upvotes: -1

hongchen liu
hongchen liu

Reputation: 11

echo 'export PATH="/opt/homebrew/lib/ruby/gems/3.2.0/bin:$PATH"' >> ~/.zshrc

Upvotes: 1

user22426420
user22426420

Reputation: 19

after

sudo gem install cocoapods

do

pod setup

then open new tab, check version of pod

pod --version

Upvotes: 1

Sajid Hasan
Sajid Hasan

Reputation: 31

You can also just run the following:

$ sudo gem uninstall cocoapods
Remove executables:
    pod, sandbox-pod

in addition to the gem? [Yn]  Y

and then

gem install cocoapods

Worked for me

Upvotes: 1

IAmNoob
IAmNoob

Reputation: 641

try sudo gem install -n /usr/local/bin cocoapods -v 1.8.4

then once cocoapods is successfully installed, try pod command again.

Upvotes: 1

Sohel Tanvir
Sohel Tanvir

Reputation: 51

It works for me:

brew update cocoapods
brew link cocoapods

Upvotes: 4

ProgrammerJibon
ProgrammerJibon

Reputation: 71

If you ever delete pod file from /usr/local/bin with terminal or any sudo,
you will need to install it to your bin folder,
so use:

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

Upvotes: 2

druide
druide

Reputation: 1

this link help me a lot it work now for me on catalina (patched for macbook pro 2011) with xcode 12.4. may sure that you don't have another older version on your mac, for me having an old xcode 10.x in my download folder caused me many issue, so read verbose instruction in terminal, that help me to solve my problem.

Upvotes: 0

Chithian
Chithian

Reputation: 349

CocoaPods is built with Ruby and it will be installable with the default Ruby available on macOS. You can use a Ruby Version manager, however we recommend that you use the standard Ruby available on macOS unless you know what you're doing.

sudo gem install cocoapods

Resource: https://guides.cocoapods.org/using/getting-started.html

Upvotes: 2

HappyFace
HappyFace

Reputation: 4133

For macOS:

brew install --cask cocoapods

Original answer (outdated):

brew install cocoapods
brew cask install cocoapods-app

Upvotes: 101

Paras
Paras

Reputation: 731

for M1mac people first install cocoapods

brew install cocoapods  

and if you are doing this for ios react-native

pod install

Upvotes: 53

Afzal Ali
Afzal Ali

Reputation: 1066

This worked for me

sudo apt-get install ruby-dev
sudo gem install cocoapods

Upvotes: 1

Gurpreet Singh
Gurpreet Singh

Reputation: 953

Please remove the Ruby folder from -Your Disk->Library->Ruby Deleting this folder and use sudo gem install cocoapods command to solve my issue. enter image description here

Upvotes: 2

saurabh rathod
saurabh rathod

Reputation: 1278

This Step Is Proper Working.

Pod Install

[ 1 ] Open terminal and type:

sudo gem install cocoapods

Gem will get installed in Ruby inside the System library. Or try on 10.11 Mac OSX El Capitan, type:

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

If there is an error "activesupport requires Ruby version >= 2.xx", then install the latest active support first by typing in the terminal.

sudo gem install activesupport -v 4.2.6

[ 2 ] After installation, there will be a lot of messages, read them and if no error found, it means cocoa pod installation is done. Next, you need to set up the cocoa pod master repo. Type in terminal:

pod setup

And wait it will download the master repo. The size is very big (370.0MB in Dec 2016). So it can be a while. You can track the download by opening Activity and go to the Network tab and search for git-remote-https. Alternatively, you can try adding verbose to the command like so:

pod setup --verbose

[ 3 ] Once done it will output "Setup Complete", and you can create your XCode project and save it.

[ 4 ] Then in a terminal cd to "your XCode project root directory" (where your .xcodeproj file resides) and type:

pod init

[ 5 ] Then open your project's podfile by typing in terminal:

open -a Xcode Podfile

[ 6 ] Your Podfile will get open in text mode. Initially, there will be some default commands in there. Here is where you add your project's dependencies. For example, in the podfile, type

/****** These are Third party pods names ******/
pod 'OpenSSL-Universal'
pod 'IQKeyboardManager'
pod 'FTPopOverMenu'
pod 'TYMActivityIndicatorView'
pod 'SCSkypeActivityIndicatorView'
pod 'Google/SignIn'
pod 'UPStackMenu'

(this is For example of adding library to your project).

When you are done editing the podfile, save it and close XCode.

[ 7 ] Then install pods into your project by typing in terminal:

pod install

Depending on how many libraries you added to your podfile for your project, the time to complete this varies. Once completed, there will be a message that says

"Pod installation complete! There are X dependencies from the Podfile and X total pods installed."

Upvotes: 114

Snowcrash
Snowcrash

Reputation: 86317

OK, found the problem. I upgraded Ruby some time ago and blasted away a whole load of gems. Solution:

sudo gem install cocoapods

For none-sudo use:

export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
gem install cocoapods --user-install

Upvotes: 657

Igor Kuzmin
Igor Kuzmin

Reputation: 11

The best solution for Big Sur is posted on Redit by _fgmx

Go into Xcode 12 preferences Click locations Select Xcode 12 for Developer tools/command line tools Install cocoapods for Xcode 12: sudo gem install cocoapods

Upvotes: 1

Helder Itiro Alves
Helder Itiro Alves

Reputation: 21

I'm using OS Catalina and used the solution of Babul Prabhakar. But when I closed the terminal, pod still was unable.

So I put the exports:

$ export GEM_HOME=$HOME/Software/ruby
$ export PATH=$PATH:$HOME/Software/ruby/bin

inside this file(put this command below inside the terminal):

nano ~/.bash_profile

Then save the file, close the terminal and open it up again and type:

pod --version

Upvotes: 1

Ranjoy Sen
Ranjoy Sen

Reputation: 1

Install pod sudo gem install cocoapods

Navigate inside platforms/ios cd platforms/ios

Run pod install

Upvotes: 0

Ayush  Kovind
Ayush Kovind

Reputation: 61

so I also had the same problem. This is probably happening because your computer has an older version of ruby. So you need to first update your ruby. Mine worked for ruby 2.6.3 version.I got this solution from sStackOverflow,

You need to first open terminal and put this code

curl -L https://get.rvm.io | bash -s stable

Then put this command

rvm install ruby-2.6

This would install the ruby for you if it hasn' t been installed.After this just update the ruby to the new version

rvm use ruby-2.6.3

After this just make ruby 2.6.3 your default

rvm --default use 2.6.3

This would possibly fix your issue. You can now put the command

sudo gem install cocoapods

And the command

pod setup

I hope this was useful

Upvotes: 6

vijay
vijay

Reputation: 11027

install cocoapods from https://cocoapods.org/app

Commands & versions keep onchanging

so download tar and enjoy

Upvotes: 3

Per Quested Aronsson
Per Quested Aronsson

Reputation: 12140

Sudo-less installation

If you do not want to grant RubyGems admin privileges for this process, you can tell RubyGems to install into your user directory by passing either the --user-install flag to gem install or by configuring the RubyGems environment. The latter is in our opinion the best solution. To do this, create or edit the .profile file in your home directory and add or amend it to include these lines:

export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH

Note that if you choose to use the --user-install option, you will still have to configure your .profile file to set the PATH or use the command prepended by the full path. You can find out where a gem is installed with gem which cocoapods. E.g.

$ gem install cocoapods --user-install
$ gem which cocoapods
/Users/eloy/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods.rb
$ /Users/eloy/.gem/ruby/2.0.0/bin/pod install

Source: https://guides.cocoapods.org/using/getting-started.html

Upvotes: 13

Shaheen
Shaheen

Reputation: 319

  1. Uninstall all instances of cocopods by this command

    $sudo gem uninstall cocoapods
    
  2. sudo gem install -n /usr/local/bin cocoapods

  3. sudo chmod +rx /usr/local/bin/

Upvotes: 18

SomnusLee
SomnusLee

Reputation: 431

@Babul Prabhakar was right

IMPORTANT: However,if you still get "pod: command not found" after using his solution, this command could solve your problem:

sudo chown -R $(whoami):admin /usr/local

Upvotes: 3

YPCrumble
YPCrumble

Reputation: 28722

If you used homebrew to install ruby, this answer worked for me.

brew unlink ruby && brew link ruby

OSX 10.9.4

Upvotes: 2

naveed148
naveed148

Reputation: 548

This solution worked for me. Make sure to not miss the last command (export PATH=$PATH:$HOME/Software/ruby/bin).

See This.

Upvotes: 3

Babul Prabhakar
Babul Prabhakar

Reputation: 2403

Installing CocoaPods on OS X 10.11

These instructions were tested on all betas and the final release of El Capitan.

Custom GEM_HOME

This is the solution when you are receiving above error

$ mkdir -p $HOME/Software/ruby
$ export GEM_HOME=$HOME/Software/ruby
$ gem install cocoapods
[...]
1 gem installed
$ export PATH=$PATH:$HOME/Software/ruby/bin
$ pod --version
0.38.2

Upvotes: 99

Crashalot
Crashalot

Reputation: 34523

We were using an incompatible version of Ruby inside of Terminal (Mac), but once we used RVM to switch to Ruby 2.1.2, Cocoapods came back.

Upvotes: 0

Nora
Nora

Reputation: 165

it happens to me when I wrote

gem install cocoapods

instead of

sudo gem install cocoapods

if sudo command is not found also, write

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH

before sudo command

Upvotes: 1

Related Questions