Commit 12853fa6 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Resolver] Show a helpful error message if the old resolver incorrectly…

[Resolver] Show a helpful error message if the old resolver incorrectly activated a   pre-release version that now leads to a version conflict
parent 1ccc1c7d
......@@ -4,6 +4,15 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
To install release candidates run `[sudo] gem install cocoapods --pre`
## Master
##### Bug Fixes
* Show a helpful error message if the old resolver incorrectly activated a
pre-release version that now leads to a version conflict.
[Samuel Giddins](https://github.com/segiddins)
## 0.35.0.rc2
##### Enhancements
......
......@@ -55,7 +55,7 @@ module Pod
@activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
specs_by_target
rescue Molinillo::ResolverError => e
raise Informative, e.message
handle_resolver_error(e)
end
# @return [Hash{Podfile::TargetDefinition => Array<Specification>}]
......@@ -360,6 +360,36 @@ module Pod
end
end
# Handles errors that come out of a {Molinillo::Resolver}.
#
# @todo The check for version conflicts coming from the {Lockfile}
# requiring a pre-release version can be deleted for version 1.0,
# as it is a migration step for Lockfiles coming from CocoaPods
# versions before `0.35.0`.
#
# @return [void]
#
# @param [Molinillo::ResolverError] error
#
def handle_resolver_error(error)
case error
when Molinillo::VersionConflict
error.conflicts.each do |name, conflict|
lockfile_reqs = conflict.requirements[name_for_locking_dependency_source]
if lockfile_reqs.last && lockfile_reqs.last.prerelease? && !conflict.existing
raise Informative, 'Due to the previous naïve CocoaPods resolver, ' \
"you were using a pre-release version of `#{name}`, " \
'without explicitly asking for a pre-release version, which now leads to a conflict. ' \
'Please decide to either use that pre-release version by adding the ' \
'version requirement to your Podfile ' \
"(e.g. `pod '#{name}', '#{lockfile_reqs.map(&:requirement).join("', '")}'`) " \
"or revert to a stable version by running `pod update #{name}`."
end
end
end
raise Informative, error.message
end
# Returns the target-appropriate nodes that are `successors` of `node`,
# rejecting those that are scoped by target platform and have incompatible
# targets.
......
......@@ -342,6 +342,21 @@ module Pod
version.to_s.should == '1.4'
end
it 'shows a helpful error message if the old resolver incorrectly ' \
'activated a pre-release version that now leads to a version ' \
'conflict' do
podfile = Podfile.new do
platform :ios, '8.0'
pod 'CocoaLumberjack'
end
locked_deps = dependency_graph_from_array([Dependency.new('CocoaLumberjack', '= 2.0.0-beta2')])
resolver = Resolver.new(config.sandbox, podfile, locked_deps, SourcesManager.all)
e = lambda { puts resolver.resolve.values.flatten }.should.raise Informative
e.message.should.match(/you were using a pre-release version of `CocoaLumberjack`/)
e.message.should.match(/`pod 'CocoaLumberjack', '= 2.0.0-beta2'`/)
e.message.should.match(/`pod update CocoaLumberjack`/)
end
it 'consults all sources when finding a matching spec' do
podfile = Podfile.new do
platform :ios
......
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