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

David picture David · Nov 18, 2014 · Viewed 51.2k times · Source

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.

Answer

Davinder picture Davinder · Nov 21, 2014

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