summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorEdouard CHIN <chin.edouard@gmail.com>2026-01-13 19:04:11 +0100
committergit <svn-admin@ruby-lang.org>2026-01-26 05:56:37 +0000
commit78d9b454ce553463b8ca2b928ab0e3cf92853e57 (patch)
tree8ea12fa551b09e3d21d4986850f8d34648ce07f4 /spec/ruby
parentee32a2dc9397dfd1574551fb48349f4a6d424385 (diff)
[ruby/rubygems] Fix RubyGems not able to require the right gem:
- Fix https://github.com/ruby/rubygems/issues/9238 - ### Problem This is an issue that bites gem maintainers from time to time, with the most recent one in https://github.com/minitest/minitest/issues/1040#issuecomment-3679370619 The issue is summarized as follow: 1) A gem "X" has a feature in "lib/feature.rb" 2) Maintainer wants to extract this feature into its own gem "Y" 3) Maintainer cut a release of X without that new feature. 4) Users install the new version of X and also install the new gem "Y" since the feature is now extracted. 5) When a call to "require 'feature'" is encountered, RG will fail to load the right gem, resulting in a `LoadError`. ### Details Now that we have two gems (old version of X and new gem Y) with the same path, RubyGems will detect that `feature.rb` can be loaded from the old version of X, but if the new version of X had already been loaded, then RubyGems will raise due to versions conflicting. ```ruby require 'x' # Loads the new version of X without the feature which was extracted. require 'feature' # Rubygems see that the old version of X include that file and tries to activate the spec. ``` ### Solution I propose that RubyGems fallback to a spec that's not yet loaded. We try to find a spec by its path and filter it out in case a spec with the same name has already been loaded. Its worth to note that RubyGems already has a `find_inactive_by_path` but we can't use it. This method only checks if the spec object is active and doesn't look if other spec with the same name have been loaded. The new method we are introducing verifies this. https://github.com/ruby/rubygems/commit/f298e2c68e
Diffstat (limited to 'spec/ruby')
0 files changed, 0 insertions, 0 deletions