Cocoapods commands fail due to "No such file or directory @ dir_initialize - /Users/<username>/.cocoapods/repos (Errno::ENOENT)"

Cocoapods

Cocoapods Problem Overview


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.

Cocoapods Solutions


Solution 1 - Cocoapods

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

Solution 2 - Cocoapods

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!

Solution 3 - Cocoapods

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

Solution 4 - Cocoapods

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

Solution 5 - Cocoapods

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.

Solution 6 - Cocoapods

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

Solution 7 - Cocoapods

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!

Solution 8 - Cocoapods

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

Solution 9 - Cocoapods

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.

Solution 10 - Cocoapods

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)

Solution 11 - Cocoapods

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.

Solution 12 - Cocoapods

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDavidView Question on Stackoverflow
Solution 1 - CocoapodsDavinderView Answer on Stackoverflow
Solution 2 - CocoapodsradiovisualView Answer on Stackoverflow
Solution 3 - CocoapodsLeandro FournierView Answer on Stackoverflow
Solution 4 - CocoapodsGalView Answer on Stackoverflow
Solution 5 - CocoapodsEthan ParkerView Answer on Stackoverflow
Solution 6 - CocoapodsTimView Answer on Stackoverflow
Solution 7 - CocoapodsGabriel GoncalvesView Answer on Stackoverflow
Solution 8 - CocoapodsmdarnallView Answer on Stackoverflow
Solution 9 - CocoapodswgrView Answer on Stackoverflow
Solution 10 - CocoapodsigraczechView Answer on Stackoverflow
Solution 11 - CocoapodsdoctorBroctorView Answer on Stackoverflow
Solution 12 - CocoapodsPhani SaiView Answer on Stackoverflow