summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_source.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2024-09-06 09:34:00 +0200
committergit <[email protected]>2024-09-06 18:44:37 +0000
commitfe1bace43c73d88a5721e9b97066e746a34f135c (patch)
treebfbd1d8ffd96ce6252e5955822f1e7938e041164 /test/rubygems/test_gem_source.rb
parent2a17b4f0222a24e2ae2cd686e611f6951215387e (diff)
[rubygems/rubygems] Fix `gem install does-not-exist` being super slow
Every time a gem is not found in the Compact Index API, RubyGems will fallback to the full index, which is very slow. This is unnecessary because both indexes should be providing the same gems, so if a gem can't be found in the Compact Index API, it won't be found in the full index. We _do_ want a fallback to the full index, whenever the Compact Index API is not implemented. To detect that, we check that the API responds to the "/versions" endpoint, just like Bundler does. Before: ``` $ time gem install fooasdsfafs ERROR: Could not find a valid gem 'fooasdsfafs' (>= 0) in any repository gem 20,77s user 0,59s system 96% cpu 22,017 total ``` After: ``` $ time gem install fooasdsfafs ERROR: Could not find a valid gem 'fooasdsfafs' (>= 0) in any repository gem 5,02s user 0,09s system 91% cpu 5,568 total ``` https://github.com/rubygems/rubygems/commit/c0d6b9eea7
Diffstat (limited to 'test/rubygems/test_gem_source.rb')
-rw-r--r--test/rubygems/test_gem_source.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb
index 6baa203dcb..423abd6dd2 100644
--- a/test/rubygems/test_gem_source.rb
+++ b/test/rubygems/test_gem_source.rb
@@ -46,7 +46,7 @@ class TestGemSource < Gem::TestCase
response = Gem::Net::HTTPResponse.new "1.1", 200, "OK"
response.uri = Gem::URI("http://example")
- @fetcher.data[@gem_repo] = response
+ @fetcher.data["#{@gem_repo}versions"] = response
set = @source.dependency_resolver_set