I used to install Cocoapods by following the officially recommended way sudo gem install cocoapods
. Not anymore. Sudo
can be a bad practice.
Install Cocoa Pods In Mac Os Catalina Download
After updating to MacOS 10.15 Catalina, there are problems with Flutter. Specifically, Flutter doctor complaints about the following: Downloaded executables cannot execute on host. CocoaPods not installed. Step 1: Open terminal and type: sudo gem install cocoapods. Gem will get installed in Ruby inside System library. Or try on 10.11 Mac OSX El Capitan, type: sudo gem install -n /usr/local/bin cocoapods. 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.

Joshua Moody in the Calabash-ios repository warns:

Using sudo is inherently dangerous. Executing a gem install with sudo is even more dangerous because gems can execute code at install time. This means they could erase parts of your hard drive or publish sensitive information to the internet. Installing gems with sudo on MacOS can overwrite the pre-installed system gems which could cause internal MacOS and Xcode tools to fail.
If it does not convince you, see what others have to say:
Jesse Squires in his post “zsh could not find CocoaPods” writes that another poor suggestion is specifying the bin dir to /usr/local/bin
when installing the gem. This is not typically where you would want gems installed.
Install Cocoapods In Mac Catalina
Cocoapods sudo-less installation on a Mac with zsh
Install Cocoa Pods In Mac Os Catalina Free
To install the Cocoapods to our user directory we need to run the command:
$ gem install cocoapods --user-install
zsh: command not found
In the terminal, if we type pod --version
the shell will probably respond with error zsh: command not found
.
We need to set the PATH
to the Cocoapods gem.
Setting the path to cocoapods in the .zprofile

The official guide recommends configuring .bash_profile
. On the newest mac_os bash shell has been replaced with zsh shell, so we need to modify .zprofile
file. The file resides in our home directory.
However, this might not work too, as the path is missing the ruby version.
First, let’s find out in the terminal the full path to the cocoapods gem:
Now back to the .zprofile
to update the path:
Install Cocoa Pods In Mac Os Catalina Update
Testing the installation
How To Update Cocoapods In Mac
Let us the shell know about our changes. If we have the terminal still reload the profile file with the command source ~/.zprofile
Install Cocoa Pods In Mac Os Catalina Os
Now the command pod --version
should work. We have installed Cocoapods without sudo
and successfully added its path. That’s it.
How To Install Cocoapods In Mac
Comment Rules: The goal is to be better at our craft. If you want to post code, insert it between the tags <code></code> Critical is fine, but if you’re rude, I'll delete your stuff. Please do not put your URL in the comment text and please use your PERSONAL name or initials and not your business name, as the latter comes off like spam. Have fun and thanks for adding to the converstaions!