Fix Bundler crashing when installing very old gems:#9401
Merged
hsbt merged 1 commit intoruby:masterfrom Mar 17, 2026
Merged
Conversation
- ### Problem There is a regression where bundler can longer install gems that were packaged a long time ago, like the [memoize gem](https://rubygems.org/gems/memoize). Bundler will crash with such error: ``` Installing memoize 1.3.1 --- ERROR REPORT TEMPLATE ------------------------------------------------------- NoMethodError: undefined method 'as_list' for nil /Users/edouard/src/opensource/rubygems/lib/rubygems/dependency.rb:146:in 'Gem::Dependency#requirements_list' ``` ### Context These very old gems were packaged at the time were a `Gem::Dependency` had no ivars `requirement`. This is what the dumped gemspec looks like: ``` dependencies: - !ruby/object:Gem::Dependency name: test-unit type: :development version_requirement: version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 2.0.2 version: ``` As opposed to a gem that was packaged more recently: ``` - !ruby/object:Gem::Dependency name: minitest-global_expectations requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' ``` The change we made in ruby@cbe57bb#diff-5ccc8aa468df013cc970580e88642417da12284da6529a4885b9abf447ae95edL529 broke old gem installation. ### Solution If `requirement` isn't set in the hash, look for `version_requirements` instead.
colby-swandale
approved these changes
Mar 17, 2026
Member
|
🙏 Thanks! Is this gem being used in application on Shopify? Currently, I'm testing based on download numbers, but we're looking for a more effective way to find it. |
Collaborator
Author
Nop, it's not. It's used in my benchmarks only |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the end-user or developer problem that led to this PR?
There is a regression where bundler can no longer install gems that were packaged a long time ago, like the memoize gem.
Bundler will crash with such error:
What is your fix for the problem, implemented in this PR?
Context
These very old gems were packaged at the time were a
Gem::Dependencyhad no ivarsrequirement. This is what the dumped gemspec looks like:As opposed to a gem that was packaged more recently:
The change we made in cbe57bb#diff-5ccc8aa468df013cc970580e88642417da12284da6529a4885b9abf447ae95edL529 broke old gem installation.
Solution
If
requirementisn't set in the hash, look forversion_requirementsinstead.Make sure the following tasks are checked
cc/ @hsbt Let me know if this fix is acceptable