summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-06-16 16:09:50 -0700
committerwycats <wycats@gmail.com>2010-06-29 14:44:41 -0700
commitd68b98b061eafef31de7fab382c7f4d6f42974c4 (patch)
tree760a2391e16c209f48c4164f0d706f954ce571e8
parent0bc9d15f13a9e82bcb3d84cab58875ae4060b22e (diff)
downloadbundler-d68b98b061eafef31de7fab382c7f4d6f42974c4.tar.gz
Likewise cleaner errors for Gemfile conflicts and child dep conflicts
-rw-r--r--lib/bundler/resolver.rb41
-rw-r--r--spec/install/gems/simple_case_spec.rb48
2 files changed, 64 insertions, 25 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 128316b4fd..d2d81c4b32 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -365,6 +365,14 @@ module Bundler
end
end
+ def clean_req(req)
+ if req.to_s.include?(">= 0")
+ req.to_s.gsub(/ \(.*?\)$/, '')
+ else
+ req.to_s.gsub(/\, (runtime|development)\)$/, ')')
+ end
+ end
+
def version_conflict
VersionConflict.new(errors.keys, error_message)
end
@@ -373,24 +381,27 @@ module Bundler
output = errors.inject("") do |o, (conflict, (origin, requirement))|
o << "Bundler could not find compatible versions for gem #{conflict.inspect}:\n"
- req_string = requirement.to_s.gsub(/\, (runtime|development)\)$/, ')')
+
if origin
+ o << " In Gemfile:\n"
if requirement.required_by.first
- o << " #{requirement.required_by.first}\n"
- o << " #{req_string}\n"
+ o << " #{clean_req(requirement.required_by.first)} depends on\n"
+ o << " #{clean_req(requirement)}\n"
else
- o << " In Gemfile:\n"
- o << " #{req_string}\n"
+ o << " #{clean_req(requirement)}\n"
end
o << "\n"
- if origin.respond_to?(:required_by) && required_by = origin.required_by.first
- o << " #{required_by} depends on\n"
- o << " #{conflict} (#{origin.version})\n"
+ unless origin.respond_to?(:required_by) && required_by = origin.required_by.first
+ o << " In snapshot (Gemfile.lock):\n"
+ end
+
+ if origin.required_by.first && origin.required_by.first.name != origin.name
+ o << " #{clean_req(origin.required_by.first)} depends on\n"
+ o << " #{origin.name} (#{origin.version})\n"
else
- o << " In snapshot (Gemfile.lock):\n "
- o << " #{conflict} (#{origin.version})\n"
+ o << " #{origin.name} (#{origin.version})\n"
end
else
@@ -402,16 +413,16 @@ module Bundler
o << " In Gemfile:\n"
if requirement.required_by.first
- o << " #{requirement.required_by.first}\n"
- o << " #{req_string}\n"
+ o << " #{clean_req(requirement.required_by.first)}\n"
+ o << " #{clean_req(requirement)}\n"
else
- o << " #{req_string}\n"
+ o << " #{clean_req(requirement)}\n"
end
o << "\nRunning `bundle update` will try to resolve the conflict between your Gemfile and snapshot.\n"
else
- o << "Could not find the gem #{req_string}\n"
- o << " required by #{requirement.required_by.first}\n"
+ o << "Could not find the gem #{clean_req(requirement)}\n"
+ o << " required by #{clean_req(requirement.required_by.first)}\n"
end
end
diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb
index 9beeb5327d..83c89f4e21 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -467,6 +467,44 @@ describe "bundle install with gem sources" do
E
out.should == nice_error
end
+
+ it "causes a conflict if child dependencies conflict" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activemerchant"
+ gem "rails_fail"
+ G
+
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
+ Fetching source index for file:/Users/carlhuda/Developer/Source/bundler/tmp/gems/remote2/
+ Bundler could not find compatible versions for gem "activesupport":
+ In Gemfile:
+ activemerchant depends on
+ activesupport (>= 2.0.0)
+
+ rails_fail depends on
+ activesupport (1.2.3)
+ E
+ out.should == nice_error
+ end
+
+ it "causes a conflict if a child dependency conflicts with the Gemfile" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "rails_fail"
+ gem "activesupport", "2.3.5"
+ G
+
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
+ Fetching source index for file:/Users/carlhuda/Developer/Source/bundler/tmp/gems/remote2/
+ Bundler could not find compatible versions for gem "activesupport":
+ In Gemfile:
+ rails_fail depends on
+ activesupport (= 1.2.3)
+
+ activesupport (2.3.5)
+ E
+ out.should == nice_error
end
it "can install dependencies even if " do
@@ -483,14 +521,4 @@ describe "bundle install with gem sources" do
end
end
- # describe_sudo "it working when $GEM_HOME is owned by root" do
- # it "installs gems" do
- # install_gemfile <<-G
- # source "file://#{gem_repo1}"
- # gem 'rack'
- # G
- #
- # should_be_installed("rack 1.0.0")
- # end
- # end
end