[rubygems/rubygems] Avoid crashing with a corrupted lockfile
I did a bad thing (script that edits the Gemfile.lock directly) and
ended up with a Gemfile.lock that was completely missing some indirect
dependencies. While this is my fault and an error is reasonable, I
noticed that the error got progressively less friendly in recent
versions of bundler.
Back on Bundler 2.2.23, a corrupt lockfile like this would cause a helpful error:
Unable to find a spec satisfying minitest (>= 5.1) in the set. Perhaps the lockfile is corrupted?
Bundler 2.3.26 gave a helpful warning:
Warning:
Your lockfile was created by an old Bundler that left some things out.
Because of the missing DEPENDENCIES, we can only install gems one at a time,
instead of installing 16 at a time.
You can fix this by adding the missing gems to your Gemfile, running bundle
install, and then removing the gems from your Gemfile.
The missing gems are:
* minitest depended upon by activesupport
But then continued on and crashed while trying to report the unmet
dependency:
--- ERROR REPORT TEMPLATE -------------------------------------------------------
NoMethodError: undefined method `full_name' for nil:NilClass
lib/bundler/installer/parallel_installer.rb:127:in `block (2 levels) in check_for_unmet_dependencies'
...
Bundler 2.4.0 and up crash as above when jobs=1, but crash
even harder when run in parallel:
This commit fixes the confusing thread deadlock crash by detecting if
dependencies are missing such that we'll never be able to enqueue. When
that happens we treat it as a failure so the install can finish.
That gets us back to the NoMethodError, which this commit fixes by
using a different warning in the case where no spec is found.
[rubygems/rubygems] Avoid crashing with a corrupted lockfile
I did a bad thing (script that edits the Gemfile.lock directly) and
ended up with a Gemfile.lock that was completely missing some indirect
dependencies. While this is my fault and an error is reasonable, I
noticed that the error got progressively less friendly in recent
versions of bundler.
Something similar came up in https://github.com/rubygems/rubygems/issues/6210,
and this commit would have helped with that case as well
(although we've already handled this a different way with #6219).
Details:¶
Back on Bundler 2.2.23, a corrupt lockfile like this would cause a helpful error:
Bundler 2.3.26 gave a helpful warning:
But then continued on and crashed while trying to report the unmet
dependency:
Bundler 2.4.0 and up crash as above when jobs=1, but crash
even harder when run in parallel:
Changes¶
This commit fixes the confusing thread deadlock crash by detecting if
dependencies are missing such that we'll never be able to enqueue. When
that happens we treat it as a failure so the install can finish.
That gets us back to the
NoMethodError
, which this commit fixes byusing a different warning in the case where no spec is found.
https://github.com/rubygems/rubygems/commit/d73001a21d