summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-06-25 08:43:41 +0900
committerSamuel Giddins <segiddins@segiddins.me>2016-06-27 16:17:38 -0500
commit9585f87217e89e4f4776f6f20d5369a7d8e7313d (patch)
tree4133b2c2a14db7c709a0ad934deabaed7362e957
parent5712f9705a46f9cb2ea2775d53a90671499ecc60 (diff)
downloadbundler-9585f87217e89e4f4776f6f20d5369a7d8e7313d.tar.gz
Auto merge of #4711 - bundler:seg-spec-for-exe-match-spec-name, r=segiddins
Prefer spec name matches when searching for an exe Closes #4705. (cherry picked from commit d497e04e336fcb54f6f92acbb6665b84d11ca396)
-rw-r--r--lib/bundler/rubygems_integration.rb12
-rw-r--r--spec/commands/exec_spec.rb1
-rw-r--r--spec/install/binstubs_spec.rb27
3 files changed, 34 insertions, 6 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 28259b72ff..af2e2f2fca 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -362,19 +362,21 @@ module Bundler
def replace_bin_path(specs)
gem_class = (class << Gem; self; end)
- redefine_method(gem_class, :find_spec_for_exe) do |name, *args|
+ redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
exec_name = args.first
spec = if exec_name
- specs.find {|s| s.executables.include?(exec_name) }
+ specs.find {|s| s.name == gem_name && s.executables.include?(exec_name) } ||
+ specs.find {|s| s.executables.include?(exec_name) }
else
- specs.find {|s| s.name == name }
+ specs.find {|s| s.name == gem_name }
end
raise(Gem::Exception, "can't find executable #{exec_name}") unless spec
raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable
unless spec.name == name
- warn "Bundler is using a binstub that was created for a different gem.\n" \
- "This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
+ Bundler::SharedHelpers.major_deprecation \
+ "Bundler is using a binstub that was created for a different gem.\n" \
+ "You should run `bundle binstub #{gem_name}` " \
"to work around a system/bundle conflict."
end
spec
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index ef59c49580..52b59e5cde 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -131,7 +131,6 @@ describe "bundle exec" do
bundle! "exec rackup", :expect_err => true
expect(out).to eq("0.9.1")
- expect(err).to match("deprecated")
Dir.chdir bundled_app2 do
bundle! "exec rackup"
diff --git a/spec/install/binstubs_spec.rb b/spec/install/binstubs_spec.rb
index 78865c7f4a..0686b449bb 100644
--- a/spec/install/binstubs_spec.rb
+++ b/spec/install/binstubs_spec.rb
@@ -20,4 +20,31 @@ describe "bundle install" do
expect(system_gem_path("altbin/rackup")).to exist
end
end
+
+ describe "when multiple gems contain the same exe" do
+ before do
+ update_repo gem_repo1 do
+ build_gem "fake", "14" do |s|
+ s.executables = "rackup"
+ end
+ end
+
+ install_gemfile <<-G, :binstubs => true
+ source "file://#{gem_repo1}"
+ gem "fake"
+ gem "rack"
+ G
+ end
+
+ it "prints a deprecation notice" do
+ bundle "config major_deprecations true"
+ gembin("rackup")
+ expect(out).to include("Bundler is using a binstub that was created for a different gem.")
+ end
+
+ it "loads the correct spec's executable" do
+ gembin("rackup")
+ expect(out).to eq("1.0.0")
+ end
+ end
end