CocoaPods
troubleshooting
command line
MacOS
pod install error

Pod: command not found (bash or zsh): how to fix CocoaPods

Codemia Knowledge Hub ·

pod: command not found means your shell cannot find the CocoaPods pod command. Either CocoaPods is not installed, its install location is not on your PATH, or the Ruby environment it depends on is broken. Check Ruby, install CocoaPods with gem, make sure its directory is on PATH, then confirm with pod --version.

CocoaPods is a widely used dependency manager for iOS development that simplifies integrating third-party libraries. The message reads -bash: pod: command not found in Bash and zsh: command not found: pod in zsh, but the causes and fixes are the same:

  • CocoaPods is not installed.
  • The CocoaPods install path is not in the PATH environment variable.
  • Ruby, which CocoaPods needs, is missing or incompletely installed.
IssueExplanation
CocoaPods not installedpod command is missing because CocoaPods has not been set up on the machine.
Path variable not updatedBash does not know where to look for the pod command, even if it's installed.
Ruby environment issuesCocoaPods requires a functional Ruby environment. Issues here can affect pod.

1. Check the Ruby installation

CocoaPods runs on Ruby, so verify Ruby first:

bash
ruby -v

If Ruby is missing, install it with a package manager such as Homebrew on macOS:

bash
brew install ruby

2. Install CocoaPods

Install CocoaPods with gem:

bash
sudo gem install cocoapods

sudo gives the administrative privileges needed for a system-wide install and avoids permission errors. Installing via gem downloads packages, so you need a working internet connection.

3. Add CocoaPods to your PATH

After a successful install, the terminal must be able to find the pod command. If the shell still cannot find it, add the gem executable directory to your PATH. To find where pod is installed:

bash
which pod

Add that directory to .bash_profile, .bashrc or .zshrc. If CocoaPods was installed into /usr/local/bin, add:

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

Then reload the configuration:

bash
source ~/.bash_profile

If you use a shell other than Bash, make the change in that shell's configuration file: .zshrc for zsh, and profile.ps1 for PowerShell on macOS.

4. Verify the installation

bash
pod --version

This prints the installed CocoaPods version.

Avoiding the problem later

  • Use a Ruby version manager such as RVM or rbenv to manage Ruby environments and avoid version-related problems with CocoaPods.
  • Keep CocoaPods updated to get the latest features and security fixes.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design