Skip to content

Commit

Permalink
Consider a dangling reference in the plugin index as not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
ccutrer committed Mar 29, 2024
1 parent 731f789 commit c014b7f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bundler/lib/bundler/plugin.rb
Expand Up @@ -241,7 +241,9 @@ def hook(event, *args, &arg_blk)

# @return [String, nil] installed path
def installed?(plugin)
index.installed?(plugin)
(path = index.installed?(plugin)) &&
index.plugin_path(plugin).join(PLUGIN_FILE_NAME).file? &&
path
end

# @return [true, false] whether the plugin is loaded
Expand Down
21 changes: 21 additions & 0 deletions bundler/spec/plugins/install_spec.rb
Expand Up @@ -505,6 +505,27 @@ def exec(command, args)
bundle "exec rake -T", :raise_on_error => false
expect(err).not_to include("Plugin foo (>= 0) is not installed")
end

it "fails bundle commands gracefully when a plugin index reference is left dangling" do
build_lib "ga-plugin" do |s|
s.write "plugins.rb"
end

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
plugin 'ga-plugin', :path => "#{lib_path("ga-plugin-1.0")}"
G

expect(out).to include("Installed plugin ga-plugin")
plugin_should_be_installed("ga-plugin")

FileUtils.rm_rf(lib_path("ga-plugin-1.0"))

plugin_should_not_be_installed("ga-plugin")

bundle "check", :raise_on_error => false
expect(err).to include("Plugin ga-plugin (>= 0) is not installed")
end
end

context "inline gemfiles" do
Expand Down

0 comments on commit c014b7f

Please sign in to comment.