10

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?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Sean
  • 1,045
  • 7
  • 22
  • @Malloc: Different issue. That one, the questioner had installed CocoaPods and had it working, and then upgraded Ruby and it blew away something that was needed. This one, the questioner has just installed it and yet it doesn't work. – Peter Hosey Apr 08 '13 at 03:50
  • 1
    Did you have to run the install under `sudo`? I don't need to do that on my Mac, and just installed and started the `pod` command OK (it wasn't previously installed). This is relevant, since where `gem install` puts the execuatbles will depend on user environment, and that will be different under `sudo` – Neil Slater Apr 08 '13 at 14:15
  • 1
    If you're using the system installed Ruby you do have to run installs with `sudo` – Keith Smiley Apr 08 '13 at 15:05
  • If I try to run the command without sudo I get - ERROR: While executing gem ... (Errno::EACCES) Permission denied - /Users/s/.gem/specs – Sean Apr 09 '13 at 01:25
  • I don't even seem to have the above directory.. which worries me – Sean Apr 09 '13 at 01:26
  • @Sean: Found any solution for this? – Iducool Sep 30 '13 at 09:27

4 Answers4

12

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

Elliot
  • 6,086
  • 11
  • 45
  • 57
2

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.

gterzian
  • 535
  • 6
  • 5
2

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

CardenB
  • 21
  • 2
0

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.

Kaelin Colclasure
  • 3,925
  • 1
  • 26
  • 36