"pod init" giving error "-bash: pod: command not found" - xcode

I am trying to create a Podfile for my Xcode project for Firebase compatibility, but when I try to create it within the same file that my Xcode project is stored in, using my terminal and typing "pod init", it throws the error "-bash: pod: command not found".
I am up to date on OSX as far as I'm aware, using Sierra 10.12.1, but I am unfamiliar with the use of Podfiles, so any help here would be great, thanks.

Looks like you didn't install CocoaPods.
To do that you install it through ruby gems, like this:
sudo gem install cocoapods
If you don't have admin privileges, try:
gem install cocoapods --user-install

if the 1st command doesn't work, try the 2nd command
sudo gem install cocoapods
sudo gem install -n /usr/local/bin cocoapods
In my case, the 2nd command worked

For OS Catalina (as of December 2019)
gem install -n /usr/local/bin cocoapods

Brew install
$ brew install cocoapods
For me sudo gem install cocoapodsdid not work.
When I tried $sudo gem install -n /usr/local/bin cocoapods it threw me weird error messages. But brew install was pretty neat.

Got this error today. Was able to resolve it by making sure I had ruby in my PATH.
export PATH=/usr/bin/ruby:$PATH
Then (as suggested by answers above) run
sudo gem install cocoapods
Or
sudo gem install -n /usr/local/bin cocoapods

I ran into this problem yesterday, I reckon others in my situation will be too. So I am running a mac OS siera on a virtual machine on my windows so I can use xcode. Firstly you will need to update your version of ruby, it has been answered here: https://stackoverflow.com/a/38194139/7451779.
Once updated this just run: $ sudo gem install cocoapods
After all this $ pod init should work

Related

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
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)
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.

This terminal won't let me run or install cocoa pods because I am on MacOS Catalina Beta?

I am interested in installing one of the GitHub repos that requires installing CocoaPods. There is no problem with my terminal (seems fine in a normal macOS version). I have one problem though: terminal is not installing CocoaPods, seemingly because I'm on the macOS Catalina beta?
I did install the pod 'Card' from Podfile which finished but after that Podfile closes. I am going running "pod install" on the terminal, then the only error that I get is:
-bash: /usr/local/bin/pod: /
System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory".
Does someone know how to fix this issue for macOS Catalina?
sudo gem install -n /usr/local/bin cocoapods
worked for me
Use
brew install cocoapods --build-from-source
The Mojave bottle is linked to a different version of Ruby. The --build-from-source option will link the cocoapods gem to the Catalina version of Ruby.
I also encountered this issue when I upgraded to Catalina and XCode 11. Here's what I did to fix this:
Select Command Line Tools in XCode.
XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X
In terminal execute:
sudo gem install cocoapods -n /usr/local/bin
Try this to get cocopods works on macOS Catalina
$ brew cleanup -d -v
$ brew install cocoapods
I fixed it by installing cocoa pod again.
sudo gem install cocoapods -n /usr/local/bin
I had not been able to solve use this one
sudo gem install -n /usr/local/bin cocoapods
Before this command I ran the following command and reinstalled cocoapod.
xcode-select --install
.
This worked for me
xcode-select --install
sudo gem install -n /usr/local/bin cocoapods
I had this problem with Catalina, to solve I have to made the following steps:
Install XCode Command Line Tools, I recommend install the HomeBrew to solve that dependency:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Execute this command to reinstall cocoa pods: sudo gem install -n /usr/local/bin cocoapods
[![If cannot install new version cocoapods, example below:
1. Please remove Command line tools
sudo rm -rf /Library/Developer/CommandLineTools
2. Install new Command line tools version
sudo xcode-select --install
3. after installing run below command
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg]
Check this one, worked for me
Go to Xcode preferences -> Locations 'tab'.
Check the Command Line Tools section. If it's blank, make sure your current command line tools is selected.
XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X
Run 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
Step 5: Run pod setup
Finished :)
Try to install cocoapods using brew
brew install cocoapods --build-from-source
if u have already installed cocoapods using brew it will not let you install cocoapods
then try
brew link --overwrite cocoapods
then write
pod setup --verbose
hope it will work.

-bash: pod: command not found

I am taking a course from Udemy for iOS 10 (swift 3) programming. An app works with Firebase and Firebase requires a pod file. In the course, it said to type the following commands in Terminal to install a pod:
cd Desktop/
ln
cd dc-social
ln
pod init
But when I run the pod init command, it gives me an error:
-bash: pod: command not found
I am running macOS Sierra (the final release). What should I do? Any help would be appreciated :)
Thanks!
try to run this first
(it will ask your admin password)
sudo gem install -n /usr/local/bin cocoapods
In my case I was unable to install with gem (sudo gem install cocoapods) but successfully installed with homebrew:
brew install cocoapods
I am in the same course and got the same problem. I found out that we have to install cocapods before we run that command. So do the following in your terminal (it will ask for your password):
sudo gem install cocoapods
This will install some stuff and then you will be able to run the "init pod command".
Maybe a little late, but often you can't do a sudo when your not an admin.
Then do this, open the terminal. Change to an admin user with
su 'theadminName'
Type the admin password.
Then do
sudo gem install cocoapods

Install Cocoapods on El Capitan. "pod: command not found" [duplicate]

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?
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
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
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."
For macOS:
brew install --cask cocoapods
Original answer (outdated):
brew install cocoapods
brew cask install cocoapods-app
You have to restart Terminal after installing the gem. Or you can simply open a new tab Terminal to fix.
for M1mac people
first install cocoapods
brew install cocoapods
and if you are doing this for ios react-native
pod install
I had the same problem, running Mountain Lion with Ruby 2 installed and used instead of system ruby.
Previously I added PATH=/usr/local/bin:$PATH to my ~/.bash_profile as a way to make sure stuff installed by homebrew, including Ruby 2, took precedence over system-installed binaries.
Anyway, in this case I noticed that cocoapods would install their 'pod' binary not in /usr/local/bin but rather in /usr/local/Cellar/ruby/2.0.0-p247/bin/
So to my .bash_profile I added PATH=$PATH:/usr/local/Cellar/ruby/2.0.0-p247/bin/
and now cocoapods is working like a charm.
Uninstall all instances of cocopods by this command
$sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
sudo chmod +rx /usr/local/bin/
Try this:
sudo gem install cocoapods -V
and you must update gem to the newest release using this:
sudo gem update --system
if you want to enjoy the fast responce :)
try:
rbenv global system
and then
sudo gem install cocoapods
pod setup
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
In terminal it's better to run installation of the cocoa pods with "sudo". In other case I'm getting an error: "You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory."
So the solution is:
sudo gem install cocoapods
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
This solution worked for me. Make sure to not miss the last command (export PATH=$PATH:$HOME/Software/ruby/bin).
See This.
install cocoapods from https://cocoapods.org/app
Commands & versions keep onchanging
so download tar and enjoy
gterzian is on the right track, however, if you later update your version of ruby then you'll also have to update your .profile to point to the new versioned ruby directory. For instance, the current version of ruby is 2.0.0-p353 so you'd have to add /usr/local/Cellar/ruby/2.0.0-p353/bin to your path instead.
A better solution is to add /usr/local/opt/ruby/bin to your PATH. /usr/local/opt/ruby is actually a symlink to the current version of ruby that homebrew automatically updates when you do an upgrade. That way you'll never need to update your PATH and always be pointing to the latest version.
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
If you used homebrew to install ruby, this answer worked for me.
brew unlink ruby && brew link ruby
OSX 10.9.4
#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
Please remove the Ruby folder from -Your Disk->Library->Ruby
Deleting this folder and use sudo gem install cocoapods command to solve my issue.
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
This worked for me
sudo apt-get install ruby-dev
sudo gem install cocoapods
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
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.
Install pod
sudo gem install cocoapods
Navigate inside platforms/ios
cd platforms/ios
Run pod install
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
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.

Running pod setup gives me "bad interpreter: No such file or directory" error

Recently I tried to do pod setup and I get this error:
-bash: /usr/local/bin/pod: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory
I followed Ray Wenderlich's guide to install CocoaPods and I get this issue so I have no idea what is going on.
I encountered this problem when upgrading to Mac OS High Sierra.
This was my fix:
sudo gem install cocoapods
I found this answer on the CocoaPods issue list on Github.
This happened when I upgraded to Catalina.
I solved it by running:
sudo gem install -n /usr/local/bin ruby
sudo gem install -n /usr/local/bin cocoapods
After upgraded to High Sierra, I got the same error, just reinstalled the cocoapods
sudo gem install -n /usr/local/bin cocoapods
Same issue I was facing when I updated our system from Sierra to Mojave. Also works for Catalina
The following steps worked:
sudo gem update --system
sudo gem install -n /usr/local/bin cocoapods
I got the help from the following link.
brew link --overwrite cocoapods
This line saved my day.
i fixed it by running brew install ruby
The following worked for me:
Select Command Line Tools in XCode.
XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X
In terminal execute:
sudo gem install cocoapods -n /usr/local/bin
https://stackoverflow.com/a/60464653
While I'm trying to install again then I got another error saying that
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
Then I did this and worked fine.
sudo gem uninstall cocoapods
sudo gem install cocoapods
On my mac this solved the problem:
brew uninstall cocoapods
brew install cocoapods
After upgrading from OS X Mojave to OS X Catalina I received this message when running pod init or pod --version:
-bash: /Users/mangolassi/.gem/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
I don't like the idea of sudo gem install cocoapods so I have my .cocoapods folder in my user directory and I've modified my .bash_profile to point to it. The error I received was because the version 2.3 was hard coded in this file:
/Users/eric/.gem/bin/pod and Catalina came with 2.6.
It's possible that using sudo install would overwrite this file successfully, and probably does, but I wanted to keep my original setup.
I was able to to just modify the first shebang line of the file /Users/eric/.gem/bin/pod to have a path with 2.6 instead of 2.3 and it worked. The entire change was changing the '3' to a '6' in my chase as the version was still '2'.
for MACOS X Catalina
Tried most of the answers but none worked. If the above doesn't work try Opening Xcode preferences > Locations > selecting Command Line Tools to Xcode. Then install cocoapods
sudo gem install -n /usr/local/bin cocoapods
The error in the original post is due to an improperly configured Ruby environment. You should never use sudo to install gems, no matter how many times you see it as an accepted answer on Stack Overflow.
At a high level, setting up a proper Ruby development environment on a Mac involves six steps:
Install Homebrew (which also installs the prerequisite Apple command line tools)
Install a Ruby manager (such as chruby, rbenv, asdf, RVM) - most of these can be installed with Homebrew
Configure the Ruby manager by adding the appropriate lines to your shell file (~/.bash_profile or ~/.zshrc) - each manager will have instructions for doing this, and this is a typical step that people miss
Restart the terminal (or open a new tab) for the shell changes to take effect - another step that is often overlooked
Install a specific version of Ruby using the Ruby manager
Switch to that version of Ruby using the Ruby manager
My personal preference is chruby with ruby-install. For more details and a script that can automate this whole process, check out my answer here:
https://stackoverflow.com/a/54873916/928191
As the accepted answer mentions, you can also install Ruby with Homebrew, but you also need to make sure to set your PATH in your shell file. Instructions for this are in my answer linked above.
I came across a similar issue when I tried upgrading the cocoa pods version using:
brew upgrade cocoapods
To fix this, cocopaods had to be linked with xcodeproj using the command below:
brew link cocoapods
If the linking fails, then you should be able to link by overwriting the previously existing link as follows:
brew link --overwrite cocoapods
Fixed with
brew upgrade cocoapods
In my case nothing of the above worked. I had ruby 2.3.0 installed and I had to downgrade to 2.0.0:
gem update --system 2.0.0
The "rubyist approved" way of doing this is to install a ruby version manager (rbenv) and install cocoapods through that. Messing with sudo and your rubygems is going to lead to tears.
Find the pod file. Mine was located at usr/local/bin/pod
You'll find that the top line says version 2.3. Edit this file to the correct version number. Save a copy of the original incase you mess it up.
Try your pod related commands again.
Worked for me after days of trying everything.
vi pod
then replace the ruby path 2.3 one to the path which u get by using
which ruby command in terminal
then do pod setup it will work
this worked for me after trying all the listed solutions .
re-installing ruby solving issues on my case (error happen after I upgrade Mac OS to Monterey). it's take a bit of time to reinstall but it worked

Resources