3

I have installed Cocoapods on OS X Mavericks using the --user-install option (to avoid having to use sudo for the installation) following the instructions at http://guides.cocoapods.org/using/getting-started.html#getting-started . I have also created a .profile file in my home directory with the following:

export GEM_HOME=$HOME/gems
export PATH=$GEM_HOME/bin:$PATH

Cocoapods successfully installs, but I am unable to run the pod command.

When running it from the command line it says No such file or directory. From what I understand, it should be installed into the /Users/me/gems/bin folder. However, this folder does not exist at all - the only Ruby related folder in my home directory is /Users/me/.gem.

I have tried running /Users/me/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/bin/pod but that results in the following error:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- bundler/setup (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from .gem/ruby/2.0.0/gems/cocoapods-0.29.0/bin/pod:14:in `<main>'

...but from what I understand, I shouldn't be running it from that location directly.

Any assistance for a Cocoapods newbie appreciated!

Skoota
  • 5,280
  • 9
  • 52
  • 75

6 Answers6

4

So after a lot of research and trying different things I have managed to get this working. I am not quite sure what eventually fixed the problem, or whether it was a combination of things, but for anyone else encountering this same problem here's what I did:

  1. Installed the Xcode command line tools for Mavericks. The option to install this is no longer available in Xcode 5, so you need to download them from https://developer.apple.com/downloads . Some people seem to say they are already installed as part of Xcode 5 from the Mac App Store, whereas others say you need to manually install them. Either way, I figured that installing them again won't hurt.

  2. The error message above talked about not being able to load bundler/setup. So, I (re?)installed the bundler ruby gem gem install bundler --user-install. Interestingly, when I then attempted to run the /Users/me/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/bin/pod command again I got a different error: /Users/me/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/Gemfile not found.

  3. What was really handy is that after the installation of bundler a message appeared saying /Users/me/.gem/ruby/2.0.0/bin in your PATH, gem executables will not run. So, I checked out the contents of that folder and it contains the pod executable! Adding it to the PATH would certainly be handy, but I just ran it directly with the full path (after changing to my Xcode project folder containing the Podfile): /Users/me/.gem/ruby/2.0.0/bin/pod install and it all works!

When I ran pod install for the first time it showed a message saying Setting up CocoaPods master repo and stayed there for quite some time - I thought it had actually hung. However, it eventually completed. If you are unsure whether it is doing anything, or has hung, do ls -la ~/.cocoapods/repos/master/.git/objects/pack/ and look at the time modified/size of the file it is downloading (thanks to this comment for the hint).

Another tip for new players - when I tried to install a pod (in my case, BlocksKit) I got a message saying [!] The platform of the target Pods (iOS 4.3) is not compatible with BlocksKit (2.1.0) which has a minimum requirement of OS X 10.7 - iOS 5.0. This was a surprising message, since my project targets iOS 7.0. Apparently you don't need to specify the platform anymore, so I entirely removed the platform line from the Podfile and it all works.

Hope that this helps other people just getting started with CocoaPods!

Community
  • 1
  • 1
Skoota
  • 5,280
  • 9
  • 52
  • 75
  • 3
    Short version: **pod** is located in ~/.gem/ruby/2.0.0/bin/ . Either reference it directly in your command or add it to the path – Marmoy Oct 07 '15 at 11:19
3

After installing Mavericks, I got error with already installed cocoapods. So I ran this command to install the new updated cocoapods version, and it works now.

sudo gem install cocoapods

aqavi_paracha
  • 1,131
  • 2
  • 17
  • 38
  • 1
    OP specified that they used the --user-install option, which is used when you can't/won't use sudo – Marmoy Oct 07 '15 at 11:15
2

Thanks to the pointers in these answers, I found that the instructions for installing CocoaPods provided on the CocoaPods web site are incorrect, regarding the contents of the .profile file, specifically the path.

As Skoota noted in the question, the path $GEM_HOME/bin does not exist. A comment by Videre gives the important clue: the correct path is $GEM_HOME/ruby/2.0.0/bin.

The correct .profile contents, which works for me at least, is:

export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/ruby/2.0.0/bin:$PATH

It is also worth noting that you must quit and relaunch the Terminal application for changes to the .profile file to take effect.

label17
  • 153
  • 6
2

add:

export COCOAPODS_NO_BUNDLER=1

to your .zprofile or .bash_profile

david
  • 391
  • 3
  • 11
  • Not sure if this solution helps with the problem OP is having. However, it helped me with a `/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.9.3/Gemfile not found` found error. Actually the documentation `https://guides.cocoapods.org/using/a-gemfile.html#rubygems` gave me the clue that this solution might work for me. – moshfiqur Sep 18 '20 at 23:07
1

I use homebrew to install cocapods

First install homebrew (paste this code in terminal and hit enter)

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Second enter this

$ brew install cocoapods
Wasi Sadman
  • 1,382
  • 1
  • 15
  • 27
0

FWIW - I ran into very similar problems. None of the above helped me so maybe others could benefit from my process.

  1. Eventually just ran sudo gem uninstall cocoapods, deleting everything that I did before.
  2. Followed the steps for creating the .profile file
  3. For good measure, closed Terminal and rebooted everything.
  4. Ran gem install cocoapods which somehow didn't run into errors this time
  5. Checked the install by running gem which cocoapods which fortunately returned the correct path
  6. ran pod setup which didn't raise any errors again .

Not entirely sure what actually worked and what didn't but maybe someone will find this useful.

Mic Fok
  • 837
  • 11
  • 12