Issues installing CocoaPods

2019-04-20 20:37发布

I'm trying to get CocoaPods set up in OSX (I'm running 10.8.2) - so I run

sudo gem install cocoapods

It succeeds and I get - 'Successfully installed cocoapods-0.17.2 1 gem installed'

Then...I try pod setup '-bash: pod: command not found '

How do I get command line to recognize this command?

4条回答
ゆ 、 Hurt°
2楼-- · 2019-04-20 20:41

I had the same problem, running Mountain Lion with Ryby 2 installed and being used instead of the standard 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, take precedence over some system stuff.

Anyway, in this case I was doing sudo gem install cocoapods

and after a succesful install, when trying a 'pod setup' I would get

-bash: pod: command not found '

so 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 works like a charm.

查看更多
Lonely孤独者°
3楼-- · 2019-04-20 20:43

I had this issue. If you used brew to install ruby and nothing else works for you, try

brew unlink ruby && brew link ruby

EDIT:

I'm on OS X Mavericks 10.9.3

查看更多
够拽才男人
4楼-- · 2019-04-20 20:51

Quitting and restarting Terminal fixed it for me. Actually, I just opened a new tab in Terminal.

查看更多
Lonely孤独者°
5楼-- · 2019-04-20 21:03

It's possible that bash simply isn't finding the newly-installed pod command. When you've just installed a new command at some random location in your PATH, you often need to tell bash to "rehash" with the following command:

$ hash -r

You can then verify that the new command is (or isn't) found using:

$ which pod

Quitting and restarting Terminal will also do the trick, although that's a much heavier hammer.

查看更多
登录 后发表回答