summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2025-02-11 14:03:02 +0100
committerHiroshi SHIBATA <[email protected]>2025-02-14 16:13:27 +0900
commite59c90118e893fae3f37ca629291f37e26de48f4 (patch)
treea9722228cce6c1c25919ca7af2a8ef1a4ff457cc
parente11401f799aa9343362a37157de6fbfc1836674d (diff)
[rubygems/rubygems] Raise error when lockfile is missing deps in frozen mode
And avoid installing any gems. https://github.com/rubygems/rubygems/commit/c12700c7e4
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--lib/bundler/errors.rb4
-rw-r--r--spec/bundler/lock/lockfile_spec.rb26
3 files changed, 32 insertions, 0 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 35f2919918..da5c344354 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -638,6 +638,8 @@ module Bundler
specs = begin
resolve.materialize(dependencies)
rescue IncorrectLockfileDependencies => e
+ raise if Bundler.frozen_bundle?
+
spec = e.spec
raise "Infinite loop while fixing lockfile dependencies" if incorrect_spec == spec
diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb
index 3fa90c5eb8..9d3d89ffeb 100644
--- a/lib/bundler/errors.rb
+++ b/lib/bundler/errors.rb
@@ -254,6 +254,10 @@ module Bundler
@spec = spec
end
+ def message
+ "Bundler found incorrect dependencies in the lockfile for #{spec.full_name}"
+ end
+
status_code(41)
end
end
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
index 15834fc7b5..ce7d7fb131 100644
--- a/spec/bundler/lock/lockfile_spec.rb
+++ b/spec/bundler/lock/lockfile_spec.rb
@@ -1587,6 +1587,32 @@ RSpec.describe "the lockfile format" do
L
end
+ it "raises a clear error when frozen mode is set and lockfile is missing deps, and does not install any gems" do
+ lockfile <<-L
+ GEM
+ remote: https://gem.repo2/
+ specs:
+ myrack_middleware (1.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ myrack_middleware
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ install_gemfile <<-G, env: { "BUNDLE_FROZEN" => "true" }, raise_on_error: false
+ source "https://gem.repo2"
+ gem "myrack_middleware"
+ G
+
+ expect(err).to eq("Bundler found incorrect dependencies in the lockfile for myrack_middleware-1.0")
+ expect(the_bundle).not_to include_gems "myrack_middleware 1.0"
+ end
+
it "automatically fixes the lockfile when it's missing deps, they conflict with other locked deps, but conflicts are fixable" do
build_repo4 do
build_gem "other_dep", "0.9"