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 /lib/bundler/installer/parallel_installer.rb | |
parent | c43fbe4ebd2b519601f0b90ca98fa096799d3846 (diff) | |
download | ruby-62b3bcba5ee422d7431f90567636155358234288.tar.gz |
[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 'lib/bundler/installer/parallel_installer.rb')
-rw-r--r-- | lib/bundler/installer/parallel_installer.rb | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb index 851b6c8d41..83a381f592 100644 --- a/lib/bundler/installer/parallel_installer.rb +++ b/lib/bundler/installer/parallel_installer.rb @@ -47,13 +47,6 @@ module Bundler dependencies.all? {|d| installed_specs.include? d.name } end - # Check whether spec's dependencies are missing, which can indicate a - # corrupted lockfile - def dependencies_missing?(all_specs) - spec_names = all_specs.map(&:name) - dependencies.any? {|d| !spec_names.include? d.name } - end - # Represents only the non-development dependencies, the ones that are # itself and are in the total list. def dependencies @@ -123,11 +116,7 @@ module Bundler unmet_dependencies.each do |spec, unmet_spec_dependencies| unmet_spec_dependencies.each do |unmet_spec_dependency| found = @specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) } - if found - warning << "* #{unmet_spec_dependency}, dependency of #{spec.full_name}, unsatisfied by #{found.full_name}" - else - warning << "* #{unmet_spec_dependency}, dependency of #{spec.full_name} but missing from lockfile" - end + warning << "* #{unmet_spec_dependency}, dependency of #{spec.full_name}, unsatisfied by #{found.full_name}" end end @@ -224,8 +213,6 @@ module Bundler if spec.dependencies_installed? @specs spec.state = :enqueued worker_pool.enq spec - elsif spec.dependencies_missing? @specs - spec.state = :failed end end end |