diff options
author | Daniel Colson <danieljamescolson@gmail.com> | 2023-02-21 16:27:54 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-03-01 02:50:40 +0000 |
commit | 62b3bcba5ee422d7431f90567636155358234288 (patch) | |
tree | 08bb8cd55dede1b41a6d3036fb0c0bd3e0603a86 /spec/bundler | |
parent | c43fbe4ebd2b519601f0b90ca98fa096799d3846 (diff) |
[rubygems/rubygems] Auto-heal on corrupted lockfile with missing deps
Following up on https://github.com/rubygems/rubygems/pull/6355, which
turned a crash into a nicer error message, this commit auto-heals the
corrupt lockfile instead.
In this particular case (a corrupt Gemfile.lock with missing
dependencies) the LazySpecification will not have accurate dependency
information, we have to materialize the SpecSet to determine there are
missing dependencies. We've already got a way to handle this, via
`SpecSet#incomplete_specs`, but it wasn't quite working for this case
because we'd get to `@incomplete_specs += lookup[name]` and
`lookup[name]` would be empty for the dependency.
With this commit we catch it a bit earlier, marking the parent spec
containing the missing dependency as incomplete.
https://github.com/rubygems/rubygems/commit/486ecb8f20
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/lock/lockfile_spec.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 88016189e6..185e2a85fa 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -1221,7 +1221,7 @@ RSpec.describe "the lockfile format" do and include("Either installing with `--full-index` or running `bundle update rack_middleware` should fix the problem.") end - it "errors gracefully on a corrupt lockfile" do + it "auto-heals when the lockfile is missing dependent specs" do build_repo4 do build_gem "minitest-bisect", "1.6.0" do |s| s.add_dependency "path_expander", "~> 1.1" @@ -1253,10 +1253,25 @@ RSpec.describe "the lockfile format" do L cache_gems "minitest-bisect-1.6.0", "path_expander-1.1.1", :gem_repo => gem_repo4 - bundle :install, :raise_on_error => false + bundle :install - expect(err).not_to include("ERROR REPORT TEMPLATE") - expect(err).to include("path_expander (~> 1.1), dependency of minitest-bisect-1.6.0 but missing from lockfile") + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + minitest-bisect (1.6.0) + path_expander (~> 1.1) + path_expander (1.1.1) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + minitest-bisect + + BUNDLED WITH + #{Bundler::VERSION} + L end it "auto-heals when the lockfile is missing specs" do |