class Bundler::Resolver
def error_message
def error_message errors.inject("") do |o, (conflict, (origin, requirement))| # origin is the SpecSet of specs from the Gemfile that is conflicted with if origin o << %{Bundler could not find compatible versions for gem "#{origin.name}":\n} o << " In Gemfile:\n" o << gem_message(requirement) # If the origin is "bundler", the conflict is us if origin.name == "bundler" o << " Current Bundler version:\n" other_bundler_required = !requirement.requirement.satisfied_by?(origin.version) # If the origin is a LockfileParser, it does not respond_to :required_by elsif !origin.respond_to?(:required_by) || !(origin.required_by.first) o << " In snapshot (Gemfile.lock):\n" end o << gem_message(origin) # If the bundle wants a newer bundler than the running bundler, explain if origin.name == "bundler" && other_bundler_required o << "This Gemfile requires a different version of Bundler.\n" o << "Perhaps you need to update Bundler by running `gem install bundler`?" end # origin is nil if the required gem and version cannot be found in any of # the specified sources else # if the gem cannot be found because of a version conflict between lockfile and gemfile, # print a useful error that suggests running `bundle update`, which may fix things # # @base is a SpecSet of the gems in the lockfile # conflict is the name of the gem that could not be found if locked = @base[conflict].first o << "Bundler could not find compatible versions for gem #{conflict.inspect}:\n" o << " In snapshot (Gemfile.lock):\n" o << " #{clean_req(locked)}\n\n" o << " In Gemfile:\n" o << gem_message(requirement) o << "Running `bundle update` will rebuild your snapshot from scratch, using only\n" o << "the gems in your Gemfile, which may resolve the conflict.\n" # the rest of the time, the gem cannot be found because it does not exist in the known sources else if requirement.required_by.first o << "Could not find gem '#{clean_req(requirement)}', which is required by " o << "gem '#{clean_req(requirement.required_by.first)}', in any of the sources." else o << "Could not find gem '#{clean_req(requirement)} in any of the sources\n" end end end o end end