Skip to content

Commit c014b7f

Browse files
committed
Consider a dangling reference in the plugin index as not installed
1 parent 731f789 commit c014b7f

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
@@ -505,6 +505,27 @@ def exec(command, args)
505505
bundle "exec rake -T", :raise_on_error => false
506506
expect(err).not_to include("Plugin foo (>= 0) is not installed")
507507
end
508+
509+
it "fails bundle commands gracefully when a plugin index reference is left dangling" do
510+
build_lib "ga-plugin" do |s|
511+
s.write "plugins.rb"
512+
end
513+
514+
install_gemfile <<-G
515+
source "#{file_uri_for(gem_repo1)}"
516+
plugin 'ga-plugin', :path => "#{lib_path("ga-plugin-1.0")}"
517+
G
518+
519+
expect(out).to include("Installed plugin ga-plugin")
520+
plugin_should_be_installed("ga-plugin")
521+
522+
FileUtils.rm_rf(lib_path("ga-plugin-1.0"))
523+
524+
plugin_should_not_be_installed("ga-plugin")
525+
526+
bundle "check", :raise_on_error => false
527+
expect(err).to include("Plugin ga-plugin (>= 0) is not installed")
528+
end
508529
end
509530

510531
context "inline gemfiles" do

0 commit comments

Comments
 (0)