diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f29e1bce8..57c8e1e650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes -* None. - +* Do not crash if the repos dir is not setup. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#9216](https://github.com/CocoaPods/CocoaPods/issues/9216) ## 1.8.3 (2019-10-04) diff --git a/lib/cocoapods/sources_manager.rb b/lib/cocoapods/sources_manager.rb index aecfa56b6b..b627eb0110 100644 --- a/lib/cocoapods/sources_manager.rb +++ b/lib/cocoapods/sources_manager.rb @@ -113,9 +113,13 @@ def update(source_name = nil, show_output = false) end changed_spec_paths = {} - # Ceate the Spec_Lock file if needed and lock it so that concurrent + + # Do not perform an update if the repos dir has not been setup yet. + return unless repos_dir.exist? + + # Create the Spec_Lock file if needed and lock it so that concurrent # repo updates do not cause each other to fail - File.open("#{Config.instance.repos_dir}/Spec_Lock", File::CREAT) do |f| + File.open("#{repos_dir}/Spec_Lock", File::CREAT) do |f| f.flock(File::LOCK_EX) sources.each do |source| UI.section "Updating spec repo `#{source.name}`" do diff --git a/spec/unit/sources_manager_spec.rb b/spec/unit/sources_manager_spec.rb index 800b46c51b..2d7c2651b6 100644 --- a/spec/unit/sources_manager_spec.rb +++ b/spec/unit/sources_manager_spec.rb @@ -210,6 +210,11 @@ module Pod master.verify_compatibility! UI.output.should.not.match /CocoaPods 999.0 is available/ end + + it 'does not crash if the repos dir does not exist' do + sources_manager = Source::Manager.new(Pathname.new(Dir.tmpdir) + 'CocoaPods/RepoDir/DoesNotExist') + lambda { sources_manager.update }.should.not.raise + end end end end