210

Can anyone help me resolve the error in the stack trace below? This occurs when I run any pod command. I've uninstalled and reinstalled the gem with no luck.

00:44:05-David~/dev/farecast-app (master)$ pod setup
Setting up CocoaPods master repo
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/pathname.rb:422:in `open': No such file or directory @ dir_initialize - /Users/David/.cocoapods/repos (Errno::ENOENT)
    from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/pathname.rb:422:in `foreach'
    from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/pathname.rb:422:in `children'
    from /usr/local/rvm/gems/ruby-2.1.0/gems/cocoapods-0.34.4/lib/cocoapods/sources_manager.rb:63:in `all'
    from /usr/local/rvm/gems/ruby-2.1.0/gems/cocoapods-0.34.4/lib/cocoapods/user_interface/error_report.rb:127:in `repo_information'
    from /usr/local/rvm/gems/ruby-2.1.0/gems/cocoapods-0.34.4/lib/cocoapods/user_interface/error_report.rb:34:in `report'
    from /usr/local/rvm/gems/ruby-2.1.0/gems/cocoapods-0.34.4/lib/cocoapods/command.rb:63:in `report_error'
    from /usr/local/rvm/gems/ruby-2.1.0@global/gems/claide-0.7.0/lib/claide/command.rb:300:in `handle_exception'
    from /usr/local/rvm/gems/ruby-2.1.0@global/gems/claide-0.7.0/lib/claide/command.rb:274:in `rescue in run'
    from /usr/local/rvm/gems/ruby-2.1.0@global/gems/claide-0.7.0/lib/claide/command.rb:264:in `run'
    from /usr/local/rvm/gems/ruby-2.1.0/gems/cocoapods-0.34.4/lib/cocoapods/command.rb:50:in `run'
    from /usr/local/rvm/gems/ruby-2.1.0/gems/cocoapods-0.34.4/bin/pod:33:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.1.0/bin/pod:23:in `load'
    from /usr/local/rvm/gems/ruby-2.1.0/bin/pod:23:in `<main>'
    from /usr/local/rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'

UPDATE: Fixed with @KeithSmiley's suggestion.

David
  • 2,430
  • 2
  • 15
  • 13
  • 8
    Can you try removing `~/.cocoapods` with `rm -rf ~/.cocoapods` and running `pod setup` again. – Keith Smiley Nov 18 '14 at 18:25
  • 1
    @KeithSmiley I tried that and still get the same stacktrace from above when running any `pod` command, including `pod setup`. – David Nov 18 '14 at 18:28
  • 4
    Well instead of running `pod setup` you can manually clone the [specs repo](https://github.com/cocoapods/specs/) into `~/.cocoapods/repos/master`. Then you should be able to skip this step. – Keith Smiley Nov 18 '14 at 18:32
  • I was using 'git rm -rf Pods', but git doesn't actually removes the directory. For those who are stucked with this, do 'rm -rf Pods' and then 'pod install'. – Borzh Sep 16 '15 at 18:24
  • Why don't you select the answer with 440+ upvotes? – Mick F May 13 '16 at 16:09

12 Answers12

482

If the message says you are missing a lib:

I got same problem and it was fixed after running pod setup and then pod install

If the missing directory is the ruby dir you can do:

You have probably updated your osx or ruby gem recently and its PATH is still linking to the old ruby version. Fix with:

sudo gem install -n /usr/local/bin ruby

sudo gem install -n /usr/local/bin cocoapods

As said by @rendel

Renato Probst
  • 5,914
  • 2
  • 42
  • 45
Davinder
  • 5,107
  • 1
  • 11
  • 8
48

Cocoapods had an issue where their github repository had become corrupted, and this forces users to clean up their local repo manually.

A quote from the Cocoapods blog post detailing the error:

Unfortunately we've encountered a bug in libgit2 and we are going to have to force push into the Specs repository. (Also known as the ‘master’ spec repo.)

What does this mean for you? Well, basically your CocoaPods setup is going to break. You are going to have to manually delete any local copies of the Specs repository and re-clone the new version of the Specs repository. You can do that with the following commands:

The Solution:

$ sudo rm -fr ~/.cocoapods/repos/master
$ pod setup

Simply running the commands above will remove the corrupted repo and reinitialize using a clean repo. See the blogpost mentioned above for more information.

Hope this helps!

Community
  • 1
  • 1
radiovisual
  • 6,298
  • 1
  • 26
  • 41
  • 1
    @user3783005, if you are getting that error, then it means that cocoapods is either not installed, or the executable 'pods' can't be found anywhere on your `PATH` variable. use `echo $PATH` to print out your full path to start the troubleshooting process. – radiovisual Nov 03 '15 at 16:50
20

I had similar issue. I deleted Pods folder and run pod install again. Problem solved.

Leandro Fournier
  • 927
  • 1
  • 9
  • 21
20

Nothing worked for me, I had to sudo gem install cocoapods and that did the magic.

Gal
  • 1,582
  • 2
  • 14
  • 30
10

Tried a ton of stuff and the only fix for me was saying

brew install cocoapods

and then

brew link --overwrite cocoapods

Now it seems to be working fine.

Ethan Parker
  • 2,986
  • 1
  • 23
  • 29
6

It sometimes occurs when using a wrong apostrophe character in a Podfile or in a Podspec

enter image description here

Those apostrophes are default when using standard TextEdit app on OS X. I prefer Sublime Text to avoid such errors

Tim
  • 1,877
  • 19
  • 27
  • 1
    Keep in mind, that when using 'private specs' technique, cocoapods may copy your local private Podspec into a directory called "./Your_Private_Subspec_Name/Pods/Local Podspecs". So, after fixing the original podspec you better delete those "Local Podspecs" directories, because cocoapods may not update the copies correctly – Tim Jul 27 '15 at 14:13
4

QUICK SOLUTION

A good way to solve this issue is going to the specified folder and check for the file that is missing (sometimes it is there but in a rare format) and delete the file. Remove also Podfile.lock file

Then execute pod install and everything should be fine :) you don't need to remove all repos that Cocoapods have downloaded.

Done!

Gabriel Goncalves
  • 5,132
  • 3
  • 25
  • 34
  • 1
    THIS. This is the fix. Reinstalled cocoapods, linked, all kinds of stuff and nothing worked until I went into Finder and deleted the files inside the pod that was mad. Even my own answer from 2018 O.o – Ethan Parker May 16 '20 at 12:03
1

FYI - I ran into this issue on a fresh install of cocoapods. Sounds like it's a bug that is fixed in 0.36

https://github.com/CocoaPods/guides.cocoapods.org/issues/58

mdarnall
  • 715
  • 6
  • 7
1

I got a similar error. And I tried "pod setup", not working. Then I create a fake file which I was told missing, and then "pod update", works.

wgr
  • 513
  • 4
  • 9
0

I got the same problem, but I had to delete whole ./Pods/ directory in my project to be able to continue (the directory contained symlinks to files from other branch that were not deleted on branch switch)

igraczech
  • 2,408
  • 3
  • 25
  • 30
0

I know this is an older post, but I ran into this problem when moving or deleting a .h file in a local pod. Turns out this was an issue with v0.38 and the solution was to update.

See the Github issue discussion of it here.

doctorBroctor
  • 2,018
  • 1
  • 14
  • 17
0

go to project directory and type command export PATH=$PATH:$HOME/Software/ruby/bin

Phani Sai
  • 1,215
  • 19
  • 33