Skip to content

Commit a7194d7

Browse files
authored
Merge pull request #6717 from rubygems/prepare-rg-3-3-27-bundler-2-3-27
Prepare to release RubyGems 3.3.27 and Bundler 2.3.27
2 parents 23ec5b8 + 2ad99fa commit a7194d7

21 files changed

+349
-261
lines changed

.github/workflows/bundler.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
- { name: Ubuntu, value: ubuntu-20.04 }
2424

2525
ruby:
26-
- { name: ruby-2.3, value: 2.3.8 }
27-
- { name: ruby-2.4, value: 2.4.10 }
26+
# - { name: ruby-2.3, value: 2.3.8 }
27+
# - { name: ruby-2.4, value: 2.4.10 }
2828
- { name: ruby-2.5, value: 2.5.9 }
2929
- { name: ruby-2.6, value: 2.6.10 }
3030
- { name: ruby-2.7, value: 2.7.6 }
@@ -36,8 +36,8 @@ jobs:
3636
- { name: 3, value: 3.0.0 }
3737

3838
exclude:
39-
- { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.3, value: 2.3.8 } }
40-
- { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.4, value: 2.4.10 } }
39+
# - { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.3, value: 2.3.8 } }
40+
# - { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.4, value: 2.4.10 } }
4141
- { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.5, value: 2.5.9 } }
4242
- { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.6, value: 2.6.10 } }
4343

.github/workflows/older-rubygems-bundler.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
include:
27-
- { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.3, value: 2.3.8 }, rgv: { name: rgv-2.5, value: v2.5.2 } }
28-
- { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.4, value: 2.4.10 }, rgv: { name: rgv-2.6, value: v2.6.14 } }
27+
# - { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.3, value: 2.3.8 }, rgv: { name: rgv-2.5, value: v2.5.2 } }
28+
# - { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.4, value: 2.4.10 }, rgv: { name: rgv-2.6, value: v2.6.14 } }
2929
- { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.5, value: 2.5.9 }, rgv: { name: rgv-2.7, value: v2.7.11 } }
3030
- { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.6, value: 2.6.10 }, rgv: { name: rgv-3.0, value: v3.0.9 } }
31-
- { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.7, value: 2.7.6 }, rgv: { name: rgv-3.1, value: v3.1.6 } }
31+
# - { bundler: { name: 2, value: '' }, ruby: { name: ruby-2.7, value: 2.7.6 }, rgv: { name: rgv-3.1, value: v3.1.6 } }
3232
- { bundler: { name: 2, value: '' }, ruby: { name: ruby-3.0, value: 3.0.4 }, rgv: { name: rgv-3.2, value: v3.2.33 } }
3333
- { bundler: { name: 2, value: '' }, ruby: { name: ruby-3.1, value: 3.1.2 }, rgv: { name: rgv-3.3, value: v3.3.5 } }
34-
- { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.7, value: 2.7.6 }, rgv: { name: rgv-3.1, value: v3.1.6 } }
34+
# - { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-2.7, value: 2.7.6 }, rgv: { name: rgv-3.1, value: v3.1.6 } }
3535
- { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-3.0, value: 3.0.4 }, rgv: { name: rgv-3.2, value: v3.2.33 } }
3636
- { bundler: { name: 3, value: 3.0.0 }, ruby: { name: ruby-3.1, value: 3.1.2 }, rgv: { name: rgv-3.3, value: v3.3.5 } }
3737
env:

.github/workflows/ruby-core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
target: [Rubygems, Bundler]
21+
target: [Rubygems] #, Bundler]
2222
steps:
2323
- name: Set up latest ruby as baseruby to be able to compile ruby
2424
uses: ruby/setup-ruby@v1

bundler/lib/bundler/index.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def local_search(query)
7171
when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
7272
when String then specs_by_name(query)
7373
when Gem::Dependency then search_by_dependency(query)
74+
when Array then search_by_name_and_version(*query)
7475
else
7576
raise "You can't search for a #{query.inspect}."
7677
end
@@ -173,6 +174,10 @@ def search_by_dependency(dependency)
173174
end
174175
end
175176

177+
def search_by_name_and_version(name, version)
178+
specs_by_name(name).select {|spec| spec.version == version }
179+
end
180+
176181
EMPTY_SEARCH = [].freeze
177182

178183
def search_by_spec(spec)

bundler/lib/bundler/lazy_specification.rb

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def initialize(name, version, platform, source = nil)
1313
@dependencies = []
1414
@platform = platform || Gem::Platform::RUBY
1515
@source = source
16-
@specification = nil
1716
end
1817

1918
def full_name
@@ -76,37 +75,46 @@ def to_lock
7675
def materialize_for_installation
7776
source.local!
7877

79-
candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?
80-
target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
78+
matching_specs = source.specs.search(use_exact_resolved_specifications? ? self : [name, version])
79+
return self if matching_specs.empty?
8180

82-
GemHelpers.select_best_platform_match(source.specs.search(Dependency.new(name, version)), target_platform)
81+
candidates = if use_exact_resolved_specifications?
82+
matching_specs
8383
else
84-
source.specs.search(self)
85-
end
84+
target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
8685

87-
return self if candidates.empty?
86+
installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
8887

89-
__materialize__(candidates)
90-
end
88+
specification = __materialize__(installable_candidates, :fallback_to_non_installable => false)
89+
return specification unless specification.nil?
9190

92-
def __materialize__(candidates)
93-
@specification = begin
94-
search = candidates.reverse.find do |spec|
95-
spec.is_a?(StubSpecification) ||
96-
(spec.matches_current_ruby? &&
97-
spec.matches_current_rubygems?)
98-
end
99-
if search.nil? && Bundler.frozen_bundle?
100-
search = candidates.last
101-
else
102-
search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
91+
if target_platform != platform
92+
installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)
10393
end
104-
search
94+
95+
installable_candidates
10596
end
97+
98+
__materialize__(candidates)
10699
end
107100

108-
def respond_to?(*args)
109-
super || @specification ? @specification.respond_to?(*args) : nil
101+
# If in frozen mode, we fallback to a non-installable candidate because by
102+
# doing this we avoid re-resolving and potentially end up changing the
103+
# lock file, which is not allowed. In that case, we will give a proper error
104+
# about the mismatch higher up the stack, right before trying to install the
105+
# bad gem.
106+
def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
107+
search = candidates.reverse.find do |spec|
108+
spec.is_a?(StubSpecification) ||
109+
(spec.matches_current_ruby? &&
110+
spec.matches_current_rubygems?)
111+
end
112+
if search.nil? && fallback_to_non_installable
113+
search = candidates.last
114+
else
115+
search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
116+
end
117+
search
110118
end
111119

112120
def to_s
@@ -128,16 +136,8 @@ def git_version
128136

129137
private
130138

131-
def to_ary
132-
nil
133-
end
134-
135-
def method_missing(method, *args, &blk)
136-
raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
137-
138-
return super unless respond_to?(method)
139-
140-
@specification.send(method, *args, &blk)
139+
def use_exact_resolved_specifications?
140+
@use_exact_resolved_specifications ||= !source.is_a?(Source::Path) && ruby_platform_materializes_to_ruby_platform?
141141
end
142142

143143
#

bundler/spec/commands/add_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,23 @@
147147
it "adds dependency with specified github source" do
148148
bundle "add rake --github=ruby/rake"
149149

150-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake"})
150+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake"})
151151
end
152152
end
153153

154154
describe "with --github and --branch" do
155155
it "adds dependency with specified github source and branch" do
156156
bundle "add rake --github=ruby/rake --branch=master"
157157

158-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake", :branch => "master"})
158+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :branch => "master"})
159159
end
160160
end
161161

162162
describe "with --github and --ref" do
163163
it "adds dependency with specified github source and ref" do
164164
bundle "add rake --github=ruby/rake --ref=5c60da8"
165165

166-
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake", :ref => "5c60da8"})
166+
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :ref => "5c60da8"})
167167
end
168168
end
169169

bundler/spec/commands/binstubs_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
before { lockfile.gsub(system_bundler_version, "1.1.1") }
226226

227227
it "calls through to the latest bundler version" do
228-
sys_exec "bin/bundle update --bundler", :env => { "DEBUG" => "1" }
228+
sys_exec "bin/bundle update --bundler=#{Bundler::VERSION}", :env => { "DEBUG" => "1" }
229229
using_bundler_line = /Using bundler ([\w\.]+)\n/.match(out)
230230
expect(using_bundler_line).to_not be_nil
231231
latest_version = using_bundler_line[1]

bundler/spec/install/gemfile/specific_platform_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,55 @@
104104
L
105105
end
106106

107+
context "when running on a legacy lockfile locked only to RUBY" do
108+
around do |example|
109+
build_repo4 do
110+
build_gem "nokogiri", "1.3.10"
111+
build_gem "nokogiri", "1.3.10" do |s|
112+
s.platform = "arm64-darwin"
113+
s.required_ruby_version = "< #{Gem.ruby_version}"
114+
end
115+
116+
build_gem "bundler", "2.1.4"
117+
end
118+
119+
gemfile <<~G
120+
source "#{file_uri_for(gem_repo4)}"
121+
122+
gem "nokogiri"
123+
G
124+
125+
lockfile <<-L
126+
GEM
127+
remote: #{file_uri_for(gem_repo4)}/
128+
specs:
129+
nokogiri (1.3.10)
130+
131+
PLATFORMS
132+
ruby
133+
134+
DEPENDENCIES
135+
nokogiri
136+
137+
RUBY VERSION
138+
2.5.3p105
139+
140+
BUNDLED WITH
141+
2.1.4
142+
L
143+
144+
simulate_platform "arm64-darwin-22", &example
145+
end
146+
147+
it "still installs the generic RUBY variant if necessary" do
148+
bundle "update --bundler", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
149+
end
150+
151+
it "still installs the generic RUBY variant if necessary, even in frozen mode" do
152+
bundle "update --bundler", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "BUNDLE_FROZEN" => "true" }
153+
end
154+
end
155+
107156
it "doesn't discard previously installed platform specific gem and fall back to ruby on subsequent bundles" do
108157
build_repo2 do
109158
build_gem("libv8", "8.4.255.0")

bundler/spec/support/artifice/compact_index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def not_modified?(checksum)
3939
end
4040

4141
def requested_range_for(response_body)
42-
ranges = Rack::Utils.byte_ranges(env, response_body.bytesize)
42+
ranges = Rack::Utils.get_byte_ranges(env, response_body.bytesize)
4343

4444
if ranges
4545
status 206

bundler/tool/bundler/dev_gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
gem "parallel", "1.19.2" # 1.20+ is required > Ruby 2.3
1212
gem "rspec-core", "~> 3.8"
1313
gem "rspec-expectations", "~> 3.8"
14-
gem "rspec-mocks", "~> 3.11.1"
14+
gem "rspec-mocks", "~> 3.8"
1515
gem "uri", "~> 0.10.1"
1616

1717
group :doc do

0 commit comments

Comments
 (0)