summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wagenet <peter.wagenet@gmail.com>2018-02-21 16:37:27 -0800
committerPeter Wagenet <peter.wagenet@gmail.com>2018-02-22 09:33:31 -0800
commita936ef3761c1971055cc438180b43af4315f08f1 (patch)
treed91eac42b712ffaa6bc55882b001fdd14285d153
parent86e4b2a636fa2153bcd048dc084ace180cfe5c4a (diff)
downloadbundler-a936ef3761c1971055cc438180b43af4315f08f1.tar.gz
Correctly re-install extensions when running `pristine` for a git source
-rw-r--r--lib/bundler/cli/pristine.rb4
-rw-r--r--lib/bundler/source.rb18
-rw-r--r--spec/commands/pristine_spec.rb19
3 files changed, 32 insertions, 9 deletions
diff --git a/lib/bundler/cli/pristine.rb b/lib/bundler/cli/pristine.rb
index 9b9cdaa9b3..532b3e0b5b 100644
--- a/lib/bundler/cli/pristine.rb
+++ b/lib/bundler/cli/pristine.rb
@@ -30,6 +30,10 @@ module Bundler
FileUtils.rm_rf spec.full_gem_path
when Source::Git
source.remote!
+ if extension_cache_path = source.extension_cache_path(spec)
+ FileUtils.rm_rf extension_cache_path
+ end
+ FileUtils.rm_rf spec.extension_dir
FileUtils.rm_rf spec.full_gem_path
else
Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 5a1f05098b..26a3625bb1 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -54,6 +54,15 @@ module Bundler
instance_of?(Bundler::Source::Path)
end
+ def extension_cache_path(spec)
+ return unless Bundler.feature_flag.global_gem_cache?
+ return unless source_slug = extension_cache_slug(spec)
+ Bundler.user_cache.join(
+ "extensions", Gem::Platform.local.to_s, Bundler.ruby_scope,
+ source_slug, spec.full_name
+ )
+ end
+
private
def version_color(spec_version, locked_spec_version)
@@ -78,15 +87,6 @@ module Bundler
end
end
- def extension_cache_path(spec)
- return unless Bundler.feature_flag.global_gem_cache?
- return unless source_slug = extension_cache_slug(spec)
- Bundler.user_cache.join(
- "extensions", Gem::Platform.local.to_s, Bundler.ruby_scope,
- source_slug, spec.full_name
- )
- end
-
def extension_cache_slug(_)
nil
end
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 4642a8167d..de3cb8054b 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe "bundle pristine" do
build_gem "baz-dev", "1.0.0"
build_gem "very_simple_binary", &:add_c_extension
build_git "foo", :path => lib_path("foo")
+ build_git "git_with_ext", :path => lib_path("git_with_ext"), &:add_c_extension
build_lib "bar", :path => lib_path("bar")
end
@@ -22,6 +23,7 @@ RSpec.describe "bundle pristine" do
gem "weakling"
gem "very_simple_binary"
gem "foo", :git => "#{lib_path("foo")}"
+ gem "git_with_ext", :git => "#{lib_path("git_with_ext")}"
gem "bar", :path => "#{lib_path("bar")}"
gemspec
@@ -165,4 +167,21 @@ RSpec.describe "bundle pristine" do
expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/)
end
end
+
+ context "when a build config exists for a git sourced gem" do
+ let(:git_with_ext) { Bundler.definition.specs["git_with_ext"].first }
+ let(:c_ext_dir) { Pathname.new(git_with_ext.full_gem_path).join("ext") }
+ let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
+ before { bundle "config build.git_with_ext -- #{build_opt}" }
+
+ # This just verifies that the generated Makefile from the c_ext gem makes
+ # use of the build_args from the bundle config
+ it "applies the config when installing the gem" do
+ bundle! "pristine"
+
+ makefile_contents = File.read(c_ext_dir.join("Makefile").to_s)
+ expect(makefile_contents).to match(/libpath =.*#{c_ext_dir}/)
+ expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/)
+ end
+ end
end