From 2194c572673d14dc61084bf6f1ae7fef7d8f652e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 1 Sep 2019 11:57:07 +0200 Subject: Fix `bundle clean` regression It would crash when git gems with extensions were included in the bundle, but excluded through `BUNDLE_WITHOUT`. --- lib/bundler/definition.rb | 2 +- spec/commands/clean_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 01ee86a358..d6fbb0b5b7 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -317,7 +317,7 @@ module Bundler end def spec_git_paths - sources.git_sources.map {|s| File.realpath(s.path) } + sources.git_sources.map {|s| File.realpath(s.path) if File.exist?(s.path) }.compact end def groups diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 13eebd3baa..7f9f84c104 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -863,4 +863,30 @@ RSpec.describe "bundle clean" do expect(very_simple_binary_extensions_dir).not_to exist end + + it "keeps git extension directories when excluded by group", :ruby_repo do + build_git "very_simple_git_binary", &:add_c_extension + + revision = revision_for(lib_path("very_simple_git_binary-1.0")) + short_revision = revision[0..11] + + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + + group :development do + gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}" + end + G + + bundle :lock + bundle "config set without development" + bundle "config set path vendor/bundle" + bundle! "install" + bundle! :clean + + very_simple_binary_extensions_dir = + Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first + + expect(very_simple_binary_extensions_dir).to be_nil + end end -- cgit v1.2.1