zsh: command not found: pod - macOS Catalina 10.15
Asked Answered
S

7

19

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

Six answered 18/5, 2020 at 10:4 Comment(6)
Is '/usr/local/bin' in the $PATH ?Asteroid
I believe so. Just googled how to check that and found "sudo nano /etc/paths" It shows a few paths including /usr/local/binSix
In your command prompt, type echo $PATHAsteroid
/usr/local/bin: /usr/bin: /bin: /usr/sbin: /sbin: /opt/X11/bin: /Library/Apple/usr/binSix
How about ls /usr/local/bin/pod, if pod is not there, try find /Applications -name podAsteroid
It's a permission issue. I don't have access to bin folder. That's weird because the account is admin. However, I may have tried to install it the very first time with sudo and entering the root admin / pwd. What's the best way to proceed to fix this ? When I try to uninstall it says I don't have permission.Six
S
28

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)

Six answered 19/5, 2020 at 13:31 Comment(3)
This one did not work for me. The next one perfectly...Doddered
Additional reference on Ruby : rvm.io/rvm/install .Kentledge
I too face the problem. This solution worked for me...Contrary
B
21

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.

Bouncy answered 1/8, 2020 at 16:7 Comment(2)
This works for me macOS Catalina 10.15.7. I didn't even have to restart. Thanks manSparrow
I was able to uninstall all dependencies minus cocoapods itself. To uninstall that one, sudo was required.Stilbestrol
T
14

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.

Tolerance answered 13/6, 2023 at 6:56 Comment(2)
gem environment is a real gem. It revealed that the executable was there in that dir/bin, so fixing this was as simple as adding that bin to PATH. ThanksTantalum
Thank you very very much for this answer!Nika
C
5
sudo gem install cocoapods -n /usr/local/bin
Crater answered 22/7, 2023 at 5:6 Comment(2)
use this command if pod not found issue.Crater
I run pod command in terminal OK but debug on VS code or run pod -v in terminal inside IDE gets error. This command works. Thanks alot!Consol
B
1

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
Benzocaine answered 3/10, 2023 at 6:39 Comment(0)
B
1

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.

Bennink answered 5/11, 2023 at 19:0 Comment(0)
G
0

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)"
Greenlee answered 4/6 at 12:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.