def error_message
output = errors.inject("") do |o, (conflict, (origin, requirement))|
if origin
o << %{Bundler could not find compatible versions for gem "#{origin.name}":\n}
o << " In Gemfile:\n"
o << gem_message(requirement)
if origin.name == "bundler"
o << " Current Bundler version:\n"
newer_bundler_required = requirement.requirement > Gem::Requirement.new(origin.version)
elsif !origin.respond_to?(:required_by) || !(required_by = origin.required_by.first)
o << " In snapshot (Gemfile.lock):\n"
end
o << gem_message(origin)
if origin.name == "bundler" && newer_bundler_required
o << "Your version of Bundler is older than the one requested by the Gemfile.\n"
o << "Perhaps you need to update Bundler by running `gem install bundler`."
end
else
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"
else
if requirement.required_by.first
o << "Could not find gem '#{clean_req(requirement)}', required by '#{clean_req(requirement.required_by.first)}', in any of the sources\n"
else
o << "Could not find gem '#{clean_req(requirement)} in any of the sources\n"
end
end
end
o
end
end