summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-06-24 12:27:19 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-06-24 14:17:06 -0500
commit38d381f58c9c877f57338c1ffec9408bce6bda4a (patch)
treeefde1234748f07cf694bab0093ec239c11123e39
parentdca6d26833ddd9d9de658bef7274c8fa21014c44 (diff)
downloadbundler-seg-spec-for-exe-match-spec-name.tar.gz
Prefer spec name matches when searching for an exeseg-spec-for-exe-match-spec-name
-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