summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-09-01 11:57:07 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-09-01 12:24:29 +0200
commit2194c572673d14dc61084bf6f1ae7fef7d8f652e (patch)
tree07e8916dbd88ea44b0fde630ed9f2cf74eefe9bc
parentb251f0e8e887ad159de3eae35ed01f849fc52af1 (diff)
downloadbundler-2194c572673d14dc61084bf6f1ae7fef7d8f652e.tar.gz
Fix `bundle clean` regression
It would crash when git gems with extensions were included in the bundle, but excluded through `BUNDLE_WITHOUT`.
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--spec/commands/clean_spec.rb26
2 files changed, 27 insertions, 1 deletions
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