Commit 96f474f7 authored by Ben Asher's avatar Ben Asher Committed by GitHub

Merge pull request #6563 from adellibovi/improve-error-message-no-specs-found

[Resolver] Improve error message when specs not found
parents 4f166599 43ba62b8
...@@ -36,6 +36,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -36,6 +36,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Alfredo Delli Bovi](https://github.com/adellibovi) [Alfredo Delli Bovi](https://github.com/adellibovi)
[#6033](https://github.com/CocoaPods/CocoaPods/issues/6033) [#6033](https://github.com/CocoaPods/CocoaPods/issues/6033)
* Provide better error message when spec not found
[Alfredo Delli Bovi](https://github.com/adellibovi)
[#6033](https://github.com/CocoaPods/CocoaPods/issues/6033)
## 1.2.1.beta.1 (2017-03-08) ## 1.2.1.beta.1 (2017-03-08)
......
...@@ -156,6 +156,11 @@ module Pod ...@@ -156,6 +156,11 @@ module Pod
private private
# @return [Bool] Whether the analysis has updated sources repositories.
#
attr_accessor :specs_updated
alias_method :specs_updated?, :specs_updated
def validate_podfile! def validate_podfile!
validator = Installer::PodfileValidator.new(podfile) validator = Installer::PodfileValidator.new(podfile)
validator.validate validator.validate
...@@ -222,6 +227,7 @@ module Pod ...@@ -222,6 +227,7 @@ module Pod
UI.message "Skipping `#{source.name}` update because the repository is not a git source repository." UI.message "Skipping `#{source.name}` update because the repository is not a git source repository."
end end
end end
@specs_updated = true
end end
private private
...@@ -716,6 +722,7 @@ module Pod ...@@ -716,6 +722,7 @@ module Pod
specs_by_target = nil specs_by_target = nil
UI.section "Resolving dependencies of #{UI.path(podfile.defined_in_file) || 'Podfile'}" do UI.section "Resolving dependencies of #{UI.path(podfile.defined_in_file) || 'Podfile'}" do
resolver = Resolver.new(sandbox, podfile, locked_dependencies, sources) resolver = Resolver.new(sandbox, podfile, locked_dependencies, sources)
resolver.specs_updated = specs_updated?
specs_by_target = resolver.resolve specs_by_target = resolver.resolve
specs_by_target.values.flatten(1).each(&:validate_cocoapods_version) specs_by_target.values.flatten(1).each(&:validate_cocoapods_version)
end end
......
...@@ -35,6 +35,11 @@ module Pod ...@@ -35,6 +35,11 @@ module Pod
# #
attr_accessor :sources attr_accessor :sources
# @return [Bool] Whether the resolver has sources repositories up-to-date.
#
attr_accessor :specs_updated
alias specs_updated? specs_updated
# Init a new Resolver # Init a new Resolver
# #
# @param [Sandbox] sandbox @see sandbox # @param [Sandbox] sandbox @see sandbox
...@@ -438,9 +443,11 @@ module Pod ...@@ -438,9 +443,11 @@ module Pod
dependencies = conflicts.count == 1 ? 'dependency' : 'dependencies' dependencies = conflicts.count == 1 ? 'dependency' : 'dependencies'
message << "\n\nNone of your spec sources contain a spec satisfying "\ message << "\n\nNone of your spec sources contain a spec satisfying "\
"the #{dependencies}: `#{conflicts.join(', ')}`." \ "the #{dependencies}: `#{conflicts.join(', ')}`." \
"\n\nYou have either:" \ "\n\nYou have either:"
"\n * out-of-date source repos which you can update with `pod repo update`." \ unless specs_updated?
"\n * mistyped the name or version." \ message << "\n * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`."
end
message << "\n * mistyped the name or version." \
"\n * not added the source repo that hosts the Podspec to your Podfile." \ "\n * not added the source repo that hosts the Podspec to your Podfile." \
"\n\nNote: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default." "\n\nNote: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default."
......
...@@ -378,9 +378,28 @@ module Pod ...@@ -378,9 +378,28 @@ module Pod
e.message.should.match(/`AFNetworking \(= 999\.999\.999\)` required by `Podfile`/) e.message.should.match(/`AFNetworking \(= 999\.999\.999\)` required by `Podfile`/)
e.message.should.match(/None of your spec sources contain a spec satisfying the dependency: `AFNetworking \(= 999\.999\.999\)`./) e.message.should.match(/None of your spec sources contain a spec satisfying the dependency: `AFNetworking \(= 999\.999\.999\)`./)
e.message.should.match(/You have either:/) e.message.should.match(/You have either:/)
e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update`/) e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`./)
e.message.should.match(/ * mistyped the name or version./)
e.message.should.match(/ * not added the source repo that hosts the Podspec to your Podfile./)
e.message.should.match(/Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default./)
e.exit_status.should.equal(31)
end
it 'raises if repo are updated and no such version of a dependency exists' do
podfile = Podfile.new do
platform :ios
pod 'AFNetworking', '999.999.999'
end
resolver = Resolver.new(config.sandbox, podfile, empty_graph, config.sources_manager.all)
resolver.specs_updated = true
e = lambda { resolver.resolve }.should.raise NoSpecFoundError
e.message.should.match(/Unable to satisfy the following requirements/)
e.message.should.match(/`AFNetworking \(= 999\.999\.999\)` required by `Podfile`/)
e.message.should.match(/None of your spec sources contain a spec satisfying the dependency: `AFNetworking \(= 999\.999\.999\)`./)
e.message.should.match(/You have either:/)
e.message.should.not.match(/ * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`./)
e.message.should.match(/ * mistyped the name or version./)
e.message.should.match(/ * not added the source repo that hosts the Podspec to your Podfile./) e.message.should.match(/ * not added the source repo that hosts the Podspec to your Podfile./)
e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update`/)
e.message.should.match(/Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default./) e.message.should.match(/Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default./)
e.exit_status.should.equal(31) e.exit_status.should.equal(31)
end end
...@@ -400,9 +419,9 @@ module Pod ...@@ -400,9 +419,9 @@ module Pod
e.message.should.match(/None of your spec sources contain a spec satisfying the dependencies:/) e.message.should.match(/None of your spec sources contain a spec satisfying the dependencies:/)
e.message.should.match(/`AFNetworking \(= 3.0.1\), AFNetworking \(= 1.4\)`/) e.message.should.match(/`AFNetworking \(= 3.0.1\), AFNetworking \(= 1.4\)`/)
e.message.should.match(/You have either:/) e.message.should.match(/You have either:/)
e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update`/) e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`./)
e.message.should.match(/ * mistyped the name or version./)
e.message.should.match(/ * not added the source repo that hosts the Podspec to your Podfile./) e.message.should.match(/ * not added the source repo that hosts the Podspec to your Podfile./)
e.message.should.match(/ * out-of-date source repos which you can update with `pod repo update`/)
e.message.should.match(/Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default./) e.message.should.match(/Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default./)
e.exit_status.should.equal(31) e.exit_status.should.equal(31)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment