Skip to content

Commit 6daacd0

Browse files
Merge pull request #8629 from rubygems/deivid-rodriguez/false-positive-warning
Fix false positive warning about insecure materialization in frozen mode (cherry picked from commit a72b4d4)
1 parent 2a353e4 commit 6daacd0

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

bundler/lib/bundler/lazy_specification.rb

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,31 @@ def choose_compatible(candidates, fallback_to_non_installable: Bundler.frozen_bu
213213
end
214214
if search.nil? && fallback_to_non_installable
215215
search = candidates.last
216-
elsif search && search.full_name == full_name
217-
# We don't validate locally installed dependencies but accept what's in
218-
# the lockfile instead for performance, since loading locally installed
219-
# dependencies would mean evaluating all gemspecs, which would affect
220-
# `bundler/setup` performance
221-
if search.is_a?(StubSpecification)
222-
search.dependencies = dependencies
223-
else
224-
if !source.is_a?(Source::Path) && search.runtime_dependencies.sort != dependencies.sort
225-
raise IncorrectLockfileDependencies.new(self)
226-
end
216+
end
227217

228-
search.locked_platform = platform if search.instance_of?(RemoteSpecification) || search.instance_of?(EndpointSpecification)
229-
end
218+
if search
219+
validate_dependencies(search) if search.platform == platform
220+
221+
search.locked_platform = platform if search.instance_of?(RemoteSpecification) || search.instance_of?(EndpointSpecification)
230222
end
231223
search
232224
end
225+
226+
# Validate dependencies of this locked spec are consistent with dependencies
227+
# of the actual spec that was materialized.
228+
#
229+
# Note that we don't validate dependencies of locally installed gems but
230+
# accept what's in the lockfile instead for performance, since loading
231+
# dependencies of locally installed gems would mean evaluating all gemspecs,
232+
# which would affect `bundler/setup` performance.
233+
def validate_dependencies(spec)
234+
if spec.is_a?(StubSpecification)
235+
spec.dependencies = dependencies
236+
else
237+
if !source.is_a?(Source::Path) && spec.runtime_dependencies.sort != dependencies.sort
238+
raise IncorrectLockfileDependencies.new(self)
239+
end
240+
end
241+
end
233242
end
234243
end

bundler/spec/install/gems/resolving_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,10 @@
305305

306306
it "gives a meaningful error if we're in frozen mode" do
307307
expect do
308-
bundle "install --verbose", env: { "BUNDLE_FROZEN" => "true" }, raise_on_error: false
308+
bundle "install", env: { "BUNDLE_FROZEN" => "true" }, raise_on_error: false
309309
end.not_to change { lockfile }
310310

311-
expect(err).to include("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}")
312-
expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
311+
expect(err).to eq("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}, which is incompatible with the current version, #{Gem.ruby_version}")
313312
end
314313
end
315314

0 commit comments

Comments
 (0)