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

匿名 (未验证) 提交于 2019-12-03 02:52:02

问题:

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 `'     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 `
' 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 `
'

UPDATE: Fixed with @KeithSmiley's suggestion.

回答1:

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



回答2:

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!



回答3:

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



回答4:

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



回答5:

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

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



回答6:

QUICK SOLUTION

A good way to solve this issue is going to 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!



回答7:

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



回答8:

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.



回答9:

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)



回答10:

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.



回答11:

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



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!