diff options
author | The Bundler Bot <bot@bundler.io> | 2017-04-20 19:38:34 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-04-23 10:35:52 +0200 |
commit | 5f413243819568029a630c1e02c541efdd4d9b5d (patch) | |
tree | 2d516b3079841391f0909eede1d5dd9de131498d | |
parent | 5ee522ad9d1011a42ce6d6e824c6eb1b8e4f7337 (diff) | |
download | bundler-5f413243819568029a630c1e02c541efdd4d9b5d.tar.gz |
Auto merge of #5595 - bundler:jules2689-stub-spec-extension-dir, r=segiddins
Apply source and git_version to stub spec extension
Fixes https://github.com/bundler/bundler/issues/5594
`stub_specification` doesn't know what `full_name` should be because we don't have a record of the source, so it resolves to `cityhash-0.6.0` rather than `cityhash-3cfc7d01f333`
This makes `StubSpecification` aware of the source to we can still avoid loading the full spec when needed. This is done by bringing remote_specs `attr_accessor :source` to `stub_spec`, and assigning source to the `stub`.
I am probably missing some edge cases to check for though 🙈 Need to write specs.
cc @segiddins
(cherry picked from commit dcddaf98a7201483277b71ae1fb7904a15a0cc9f)
-rw-r--r-- | lib/bundler/stub_specification.rb | 13 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 5 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index 257a472224..d5f6a883f9 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -11,6 +11,19 @@ module Bundler attr_accessor :stub, :ignored + # Pre 2.2.0 did not include extension_dir + # https://github.com/rubygems/rubygems/commit/9485ca2d101b82a946d6f327f4bdcdea6d4946ea + if Bundler.rubygems.provides?(">= 2.2.0") + def source=(source) + super + # Stub has no concept of source, which means that extension_dir may be wrong + # This is the case for git-based gems. So, instead manually assign the extension dir + return unless source.respond_to?(:extension_dir_name) + path = File.join(stub.extensions_dir, source.extension_dir_name) + stub.extension_dir = File.expand_path(path) + end + end + def to_yaml _remote_specification.to_yaml end diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index d2d46279aa..8843fb7ebb 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -1030,6 +1030,11 @@ RSpec.describe "bundle install with git sources" do puts FOO R expect(out).to eq("YES") + + run! <<-R + puts $:.grep(/ext/) + R + expect(out).to eq(Pathname.glob(system_gem_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s) end it "does not use old extension after ref changes" do |