Skip to content

Commit 2428fb6

Browse files
Merge pull request #5975 from rubygems/windows-fix
Fix incorrect materialization on Windows
2 parents 5303eb2 + ab11545 commit 2428fb6

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.github/workflows/install-rubygems.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,8 @@ jobs:
121121
- name: Check we can install a Gemfile with git sources
122122
run: bundle init && bundle add fileutils --git https://github.com/ruby/fileutils
123123
shell: bash
124+
- name: Generate a Rails application
125+
run: gem install rails && rails new foo
126+
shell: bash
124127

125128
timeout-minutes: 10

bundler/lib/bundler/gem_helpers.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module GemHelpers
55
GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant
66
GENERICS = [
77
[Gem::Platform.new("java"), Gem::Platform.new("java")],
8-
[Gem::Platform.new("universal-java"), Gem::Platform.new("java")],
98
[Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")],
109
[Gem::Platform.new("mswin64"), Gem::Platform.new("mswin64")],
1110
[Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],

bundler/lib/bundler/lazy_specification.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def materialize_for_installation
7777
source.local!
7878

7979
candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?
80-
target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : Bundler.local_platform
80+
target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
8181

8282
source.specs.search(Dependency.new(name, version)).select do |spec|
8383
MatchPlatform.platforms_match?(spec.platform, target_platform)
@@ -144,15 +144,18 @@ def method_missing(method, *args, &blk)
144144

145145
#
146146
# For backwards compatibility with existing lockfiles, if the most specific
147-
# locked platform is RUBY, we keep the previous behaviour of resolving the
147+
# locked platform is not a specific platform like x86_64-linux or
148+
# universal-java-11, then we keep the previous behaviour of resolving the
148149
# best platform variant at materiliazation time. For previous bundler
149150
# versions (before 2.2.0) this was always the case (except when the lockfile
150151
# only included non-ruby platforms), but we're also keeping this behaviour
151152
# on newer bundlers unless users generate the lockfile from scratch or
152153
# explicitly add a more specific platform.
153154
#
154155
def ruby_platform_materializes_to_ruby_platform?
155-
!Bundler.most_specific_locked_platform?(generic_local_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
156+
generic_platform = generic_local_platform == Gem::Platform::JAVA ? Gem::Platform::JAVA : Gem::Platform::RUBY
157+
158+
!Bundler.most_specific_locked_platform?(generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
156159
end
157160
end
158161
end

bundler/lib/bundler/remote_specification.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def fetch_platform
3030
end
3131

3232
def identifier
33-
@__identifier ||= [name, version, @original_platform.to_s]
33+
@__identifier ||= [name, version, @platform.to_s]
3434
end
3535

3636
def full_name
37-
if @original_platform == Gem::Platform::RUBY
37+
if @platform == Gem::Platform::RUBY
3838
"#{@name}-#{@version}"
3939
else
40-
"#{@name}-#{@version}-#{@original_platform}"
40+
"#{@name}-#{@version}-#{@platform}"
4141
end
4242
end
4343

bundler/spec/bundler/remote_specification_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
let(:platform) { "jruby" }
4646

4747
it "should return the spec name, version, and platform" do
48-
expect(subject.full_name).to eq("foo-1.0.0-jruby")
48+
expect(subject.full_name).to eq("foo-1.0.0-java")
4949
end
5050
end
5151
end

0 commit comments

Comments
 (0)