@@ -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
158161end
0 commit comments