Skip to content

Commit

Permalink
Ad-hoc fix for platform regression
Browse files Browse the repository at this point in the history
We should be able to remove this once we have proper bundler version
switching.
  • Loading branch information
deivid-rodriguez committed Dec 11, 2020
1 parent a6db700 commit b7ce820
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
9 changes: 9 additions & 0 deletions bundler/lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ def locked_gems
end
end

def locked_bundler_version
return nil unless defined?(@definition) && @definition

locked_gems = definition.locked_gems
return nil unless locked_gems

locked_gems.bundler_version
end

def ruby_scope
"#{Bundler.rubygems.ruby_engine}/#{RbConfig::CONFIG["ruby_version"]}"
end
Expand Down
8 changes: 7 additions & 1 deletion bundler/lib/bundler/lazy_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ def __materialize__
search_object = if source.is_a?(Source::Path)
Dependency.new(name, version)
else
self
locked_bundler_version = Bundler.locked_bundler_version

if locked_bundler_version && Gem::Version.new(locked_bundler_version) < Gem::Version.new("2.2.0")
Dependency.new(name, version)
else
self
end
end
platform_object = Gem::Platform.new(platform)
candidates = source.specs.search(search_object)
Expand Down
29 changes: 29 additions & 0 deletions bundler/spec/install/gemfile/specific_platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,35 @@
])
end

it "understands that a non-plaform specific gem in a old lockfile doesn't necessarily mean installing the non-specific variant" do
setup_multiplatform_gem

install_gemfile(google_protobuf)

# simulate lockfile created with old bundler, which only locks for ruby platform
lockfile <<-L
GEM
remote: #{file_uri_for(gem_repo2)}/
specs:
google-protobuf (3.0.0.alpha.5.0.5.1)
PLATFORMS
ruby
DEPENDENCIES
google-protobuf
BUNDLED WITH
2.1.4
L

# force strict usage of the lock file by setting frozen mode
bundle "config set --local frozen true"

# make sure the platform that got actually installed with the old bundler is used
expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin")
end

it "caches both the universal-darwin and ruby gems when --all-platforms is passed and properly picks them up on further bundler invocations" do
setup_multiplatform_gem
gemfile(google_protobuf)
Expand Down

0 comments on commit b7ce820

Please sign in to comment.