Skip to content

Commit 7122f47

Browse files
committed
Consider a dangling reference in the plugin index as not installed
1 parent eb3cd94 commit 7122f47

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

bundler/lib/bundler/plugin.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ def hook(event, *args, &arg_blk)
240240

241241
# @return [String, nil] installed path
242242
def installed?(plugin)
243-
index.installed?(plugin)
243+
(path = index.installed?(plugin)) &&
244+
index.plugin_path(plugin).join(PLUGIN_FILE_NAME).file? &&
245+
path
244246
end
245247

246248
# Post installation processing and registering with index

bundler/spec/plugins/install_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,27 @@ def exec(command, args)
493493
bundle "exec rake -T", :raise_on_error => false
494494
expect(err).not_to include("Plugin foo (>= 0) is not installed")
495495
end
496+
497+
it "fails bundle commands gracefully when a plugin index reference is left dangling" do
498+
build_lib "ga-plugin" do |s|
499+
s.write "plugins.rb"
500+
end
501+
502+
install_gemfile <<-G
503+
source "#{file_uri_for(gem_repo1)}"
504+
plugin 'ga-plugin', :path => "#{lib_path("ga-plugin-1.0")}"
505+
G
506+
507+
expect(out).to include("Installed plugin ga-plugin")
508+
plugin_should_be_installed("ga-plugin")
509+
510+
FileUtils.rm_rf(lib_path("ga-plugin-1.0"))
511+
512+
plugin_should_not_be_installed("ga-plugin")
513+
514+
bundle "check", :raise_on_error => false
515+
expect(err).to include("Plugin ga-plugin (>= 0) is not installed")
516+
end
496517
end
497518

498519
context "inline gemfiles" do

0 commit comments

Comments
 (0)