Skip to content

Commit 0b9b632

Browse files
segiddinsdeivid-rodriguez
authored andcommitted
Merge pull request #6936 from rubygems/segiddins/force-ruby-platform-only-ruby
Fix force_ruby_platform: when the lockfile only locks the ruby platform (cherry picked from commit ed65279)
1 parent 0fbd11f commit 0b9b632

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

bundler/lib/bundler/spec_set.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def specs_for_dependency(dep, platform)
202202
specs_for_name = lookup[dep.name]
203203
target_platform = dep.force_ruby_platform ? Gem::Platform::RUBY : (platform || Bundler.local_platform)
204204
matching_specs = GemHelpers.select_best_platform_match(specs_for_name, target_platform)
205+
matching_specs.each {|s| s.force_ruby_platform = true } if dep.force_ruby_platform
205206
matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
206207
matching_specs
207208
end

bundler/spec/install/gemfile/force_ruby_platform_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,48 @@
114114
expect(the_bundle).to include_gems "depends_on_platform_specific 1.0.0 RUBY"
115115
expect(the_bundle).to include_gems "platform_specific 1.0.0 #{Bundler.local_platform}"
116116
end
117+
118+
it "uses ruby variants for the explicit transitive dependency with a lockile that has only ruby platform" do
119+
lockfile <<-L
120+
GEM
121+
remote: #{file_uri_for(gem_repo4)}
122+
specs:
123+
dep_level_2 (1.0)
124+
depends_on_platform_specific
125+
depends_on_platform_specific (1.0)
126+
platform_specific
127+
platform_specific (1.0)
128+
129+
PLATFORMS
130+
ruby
131+
132+
DEPENDENCIES
133+
dep_level_2
134+
platform_specific
135+
136+
BUNDLED WITH
137+
#{Bundler::VERSION}
138+
L
139+
140+
install_gemfile <<-G, :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }, :artifice => "compact_index", :verbose => true
141+
source "#{file_uri_for(gem_repo4)}"
142+
143+
gem "platform_specific"
144+
gem "depends_on_platform_specific"
145+
G
146+
147+
expect(the_bundle).to include_gems "depends_on_platform_specific 1.0.0 #{Bundler.local_platform}"
148+
expect(the_bundle).to include_gems "platform_specific 1.0.0 #{Bundler.local_platform}"
149+
150+
install_gemfile <<-G, :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }, :artifice => "compact_index"
151+
source "#{file_uri_for(gem_repo4)}"
152+
153+
gem "platform_specific", :force_ruby_platform => true
154+
gem "depends_on_platform_specific"
155+
G
156+
157+
expect(the_bundle).to include_gems "depends_on_platform_specific 1.0.0 #{Bundler.local_platform}"
158+
expect(the_bundle).to include_gems "platform_specific 1.0.0 RUBY"
159+
end
117160
end
118161
end

0 commit comments

Comments
 (0)