GrandSteph
GrandSteph

Reputation: 2271

zsh: command not found: pod - macOS Catalina 10.15

I'm running the install with an admin account I tried

sudo gem install cocoapods

and

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

They both run fine with following output

Fetching cocoapods-1.9.1.gem
Successfully installed cocoapods-1.9.1
Parsing documentation for cocoapods-1.9.1
Installing ri documentation for cocoapods-1.9.1
Done installing documentation for cocoapods after 2 seconds
1 gem installed

however, a simple

pod --version

Returns

zsh: command not found: pod

I'm not too good at managing users accounts or dealing with command shell but I scoured the net and couldn't find a solution. It looks like wherever pod is installed, it doesn't make it to the list of executable applications

Upvotes: 19

Views: 79494

Answers (7)

Vikas Gupta
Vikas Gupta

Reputation: 11

Use for M1, M2 M3 chipset if the brew command not working in the terminal after homebrew installation success in the system.

eval "$(/opt/homebrew/bin/brew shellenv)"

Upvotes: 1

dodov
dodov

Reputation: 5844

In my case, I already had the pod executable, but it wasn't in my PATH. For context, I've installed Ruby via Homebrew.

First I found where the executable is:

$ find /usr/local -type f -name "pod"
/usr/local/lib/ruby/gems/3.2.0/bin/pod
/usr/local/lib/ruby/gems/3.2.0/gems/cocoapods-1.14.2/bin/pod

…then I opened my ~/.profile and added it to the PATH:

export PATH="/usr/local/lib/ruby/gems/3.2.0/bin:$PATH"

Note: I have .profile loaded in both my .bash_profile:

$ cat ~/.bash_profile
source ~/.profile

…and my .zprofile:

$ cat ~/.zprofile
emulate sh
source ~/.profile
emulate zsh

…so both bash and zsh get the updated PATH.

Upvotes: 1

dpacman
dpacman

Reputation: 3899

I tried the above answers installing Ruby with rvm, but it failed because of make error. Here is how I installed it with rbenv:

  1. Install rbenv:
brew install rbenv
  1. Initialize rbenv:
rbenv init

You'll need to follow the printed instructions to set up rbenv integration with your shell. This is a step you'll only need to do once.

  1. Install Ruby 2.7.4 (or any version above):
rbenv install 2.7.4
  1. Set Ruby 2.7.4 as the default version for your local system:
rbenv global 2.7.4
  1. Verify that the correct version of Ruby is now in use:
ruby -v
  1. Now install cocoapods
sudo gem install cocoapods

Upvotes: 1

Prabhakar Azad
Prabhakar Azad

Reputation: 117

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

Upvotes: 8

Farras Doko
Farras Doko

Reputation: 547

If you're encountering the "zsh: command not found: pod" error after successfully installing CocoaPods, it could be due to the pod executable not being included in your system's PATH. To resolve this issue, you can try the following steps:

  1. Check if the pod executable is present in the /usr/local/bin/ directory. Run the following command in terminal:
ls /usr/local/bin/pod
  1. If the pod executable is listed, Add the CocoaPods executable directory to your system's PATH. Open your shell's configuration file using a text editor. Run the following command in terminal:
open ~/.zshrc
  1. In the configuration file, add the following line:
export PATH="$PATH:/usr/local/bin"
  1. Reload the shell's configuration by running:
source ~/.zshrc
  1. Verify that CocoaPods is now accessible by running:
pod --version

It should display the version number of CocoaPods if the setup was successful.

But if the pod executable is not present in the /usr/local/bin/ directory after installing CocoaPods, it might be due to an issue during the installation process. To troubleshoot this, you can try the following steps:

  1. Ensure that Ruby and CocoaPods are installed correctly. Run the following commands to verify their installations:
ruby --version
gem --version

If both commands display the version numbers without any errors, proceed to the next step. Otherwise, you may need to reinstall Ruby and CocoaPods.

  1. Verify the installation location of the CocoaPods gem. Run the following command to check the gem installation paths:
gem environment

Look for the line that starts with "INSTALLATION DIRECTORY". Make a note of the path listed next to it.

  1. Check if the CocoaPods executable is present in the installation path. Run the following command, replacing <INSTALLATION_PATH> with the path obtained from the previous step:
ls <INSTALLATION_PATH>/bin/pod
  1. If the pod executable is listed, add the CocoaPods executable path to your system's PATH. Open your shell's configuration file using a text editor. For Zsh, you can use the following command:
open ~/.zshrc
  1. In the configuration file, add the following line, replacing <INSTALLATION_PATH> with the actual path from Step 2:
export PATH="<INSTALLATION_PATH>/bin:$PATH"
  1. Reload the shell's configuration by running:
source ~/.zshrc
  1. Verify that CocoaPods is now accessible by running:
pod --version

If the pod command displays the version number of CocoaPods, then the setup was successful.

If you're still experiencing issues after following these steps, it's recommended to uninstall and reinstall CocoaPods using a different method, such as using a package manager like Homebrew.

Upvotes: 23

Gwamaka Charles
Gwamaka Charles

Reputation: 1695

I followed these instructions but ended up with the same issue. So I ran gem list | grep cocoapods and then uninstalled every instance of cocoapods with gem uninstall cocoapods along with the executables. Then I decided to install cocoapods using Homebrew with brew install cocoapods, restarted my Mac and the pod command was available. Remember I didn't restart my Mac after using sudo gem install cocoapods,maybe that will work too, you can try.

Upvotes: 22

GrandSteph
GrandSteph

Reputation: 2271

The issue was that command line for XCODE was not installed.

First I updated to latest Ruby version and put the version number in the second command (in place of [version]

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

rvm install ruby-[version] 

During the install you will see the Software update available from MAcOS popup. Install immediately and continue with prompts in that window (I believe it asks for updates and then asks for install.

It will take a while to run / download / install (it took 2 expressos for me :) )

After that I ran

sudo gem install cocoapods

And restarted my terminal. Now checking it's installed

pod --version

Returns the installed version (1.9.1 for me)

Upvotes: 28

Related Questions