Skip to content

Commit f852f3d

Browse files
Merge pull request #8483 from rubygems/deivid-rodriguez/fail-hard-when-lockfile-is-missing-deps-in-frozen-mode
Raise error when lockfile is missing deps in frozen mode (cherry picked from commit 126cfe2)
1 parent 371641d commit f852f3d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

bundler/lib/bundler/definition.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ def materialize(dependencies)
638638
specs = begin
639639
resolve.materialize(dependencies)
640640
rescue IncorrectLockfileDependencies => e
641+
raise if Bundler.frozen_bundle?
642+
641643
spec = e.spec
642644
raise "Infinite loop while fixing lockfile dependencies" if incorrect_spec == spec
643645

bundler/lib/bundler/errors.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ def initialize(spec)
254254
@spec = spec
255255
end
256256

257+
def message
258+
"Bundler found incorrect dependencies in the lockfile for #{spec.full_name}"
259+
end
260+
257261
status_code(41)
258262
end
259263
end

bundler/spec/lock/lockfile_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,32 @@
15871587
L
15881588
end
15891589

1590+
it "raises a clear error when frozen mode is set and lockfile is missing deps, and does not install any gems" do
1591+
lockfile <<-L
1592+
GEM
1593+
remote: https://gem.repo2/
1594+
specs:
1595+
myrack_middleware (1.0)
1596+
1597+
PLATFORMS
1598+
#{lockfile_platforms}
1599+
1600+
DEPENDENCIES
1601+
myrack_middleware
1602+
1603+
BUNDLED WITH
1604+
#{Bundler::VERSION}
1605+
L
1606+
1607+
install_gemfile <<-G, env: { "BUNDLE_FROZEN" => "true" }, raise_on_error: false
1608+
source "https://gem.repo2"
1609+
gem "myrack_middleware"
1610+
G
1611+
1612+
expect(err).to eq("Bundler found incorrect dependencies in the lockfile for myrack_middleware-1.0")
1613+
expect(the_bundle).not_to include_gems "myrack_middleware 1.0"
1614+
end
1615+
15901616
it "automatically fixes the lockfile when it's missing deps, they conflict with other locked deps, but conflicts are fixable" do
15911617
build_repo4 do
15921618
build_gem "other_dep", "0.9"

0 commit comments

Comments
 (0)