Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not crash if the repos dir is not setup. #9234

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions lib/cocoapods/sources_manager.rb
Expand Up @@ -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|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured thats what the sources_manager get initialized with. I dont think we will ever have this case but if you had 2 sources_manager instances with two different folders they would have to wait for each other for the operation to be completed but they shouldn't have to?

f.flock(File::LOCK_EX)
sources.each do |source|
UI.section "Updating spec repo `#{source.name}`" do
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/sources_manager_spec.rb
Expand Up @@ -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