Crash when repo update
Closed this issue · 9 comments
I run the pod repo update --verbose
. I found that there are some bad repos in my CocoaPods Source, and there is a crash bug in CP:
Stack
CocoaPods : 1.5.3
Ruby : ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
RubyGems : 2.7.6
Host : Mac OS X 10.13.6 (17G65)
Xcode : 10.1 (10B61)
Git : git version 2.17.2 (Apple Git-113)
Ruby lib dir : /Users/user/.rvm/rubies/ruby-2.5.1/lib
Repositories :
Plugins
cocoapods-deintegrate : 1.0.2
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.3.1
cocoapods-try : 1.1.0
Error
NoMethodError - undefined method `bsearch' for #<Enumerator: []:reverse_each>
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-core-1.5.3/lib/cocoapods-core/source/metadata.rb:56:in `last_compatible_version'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-core-1.5.3/lib/cocoapods-core/source.rb:347:in `update'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/lib/cocoapods/sources_manager.rb:88:in `block (2 levels) in update'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/lib/cocoapods/sources_manager.rb:87:in `block in update'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/lib/cocoapods/sources_manager.rb:86:in `each'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/lib/cocoapods/sources_manager.rb:86:in `update'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/lib/cocoapods/command/repo/update.rb:23:in `run'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/cocoapods-1.5.3/bin/pod:55:in `<top (required)>'
/Users/aweme/.rvm/gems/ruby-2.5.1/bin/pod:23:in `load'
/Users/aweme/.rvm/gems/ruby-2.5.1/bin/pod:23:in `<top (required)>'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/cli/exec.rb:74:in `load'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/cli/exec.rb:28:in `run'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/cli.rb:424:in `exec'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/cli.rb:27:in `dispatch'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/cli.rb:18:in `start'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/exe/bundle:30:in `block in <top (required)>'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/Users/aweme/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.5/exe/bundle:22:in `<top (required)>'
/Users/aweme/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `load'
/Users/aweme/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `<main>'
Is this an issue with the metadata included in your private repos?
It should be located at CocoaPods-version.yml
and look something like this:
min: 1.0.0
last: 1.6.0.beta.2
prefix_lengths:
- 1
- 1
- 1
I known. I remove the bad repo,and it works.
I think that there is a bug forbsearch
.
What was in the metadata for the repo that caused the crash?
Somebody want to deprecate the repo, and he set the metadata:
---
min: 2.0.0
last: 2.0.0
The pod repo update
will update all repos in my mac, include the Deprecated repo.
I don't care the metadata in the repo, because the repo will not be used in the future.
But the pod will crash when the metadata is invalid.
NoMethodError - undefined method `bsearch' for #<Enumerator: []:reverse_each>
def last_compatible_version(target_version)
return unless minimum_cocoapods_version
return if minimum_cocoapods_version <= target_version
@last_compatible_versions.reverse_each.bsearch { |v| v <= target_version }.tap do |version|
raise Informative, 'Unable to find compatible version' unless version
end
end
The bsearch
is a method of Array
, not Enumerator
.
❯ irb
2.5.0 :001 > [].bsearch {}
=> nil
2.5.0 :002 > [].reverse_each.bsearch {}
Traceback (most recent call last):
2: from /Users/whirlwind/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
1: from (irb):2
NoMethodError (undefined method `bsearch' for #<Enumerator: []:reverse_each>)
Is it right?
hmm yeah, seems like we should be converting it to an array then
hmm yeah, seems like we should be converting it to an array then
So, has this bug been solved? I have the same issue on ruby 2.3, cocoapods 1.5.3.
it hasn't - I will try to take a look at this when I get the chance.
@qwertyI @Whirlwind do either of you have a spec repo I can test this with? or just a complete metadata file that reproduces the crash would be helpful