Skip to content

Commit bcc8fb7

Browse files
committed
Consider a dangling reference in the plugin index as not installed
1 parent 43ab86c commit bcc8fb7

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
@@ -241,7 +241,9 @@ def hook(event, *args, &arg_blk)
241241

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

247249
# @return [true, false] whether the plugin is loaded

bundler/spec/plugins/install_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,27 @@ def exec(command, args)
548548
bundle "exec rake -T", raise_on_error: false
549549
expect(err).not_to include("Plugin foo (>= 0) is not installed")
550550
end
551+
552+
it "fails bundle commands gracefully when a plugin index reference is left dangling" do
553+
build_lib "ga-plugin" do |s|
554+
s.write "plugins.rb"
555+
end
556+
557+
install_gemfile <<-G
558+
source "#{file_uri_for(gem_repo1)}"
559+
plugin 'ga-plugin', :path => "#{lib_path("ga-plugin-1.0")}"
560+
G
561+
562+
expect(out).to include("Installed plugin ga-plugin")
563+
plugin_should_be_installed("ga-plugin")
564+
565+
FileUtils.rm_rf(lib_path("ga-plugin-1.0"))
566+
567+
plugin_should_not_be_installed("ga-plugin")
568+
569+
bundle "check", raise_on_error: false
570+
expect(err).to include("Plugin ga-plugin (>= 0) is not installed")
571+
end
551572
end
552573

553574
context "inline gemfiles" do

0 commit comments

Comments
 (0)