rubygems-mirror icon indicating copy to clipboard operation
rubygems-mirror copied to clipboard

`gem mirror` should also download the `/versions` file and the `/info/` directory

Open iBug opened this issue 1 year ago • 4 comments

According to issues like:

A full RubyGems mirror generated by gem mirror is not easy to consume - Both gem install and bundle fetches tons of gemspec.rz files if a faster index is not found (previously /api/v1/dependencies, now superseded by /versions + /info/), making a local mirror actually much slower even under terrible availability of rubygems.org (e.g. from mainland China).

If gem mirror could also fetch the versions file and populate the /info/ directory, downstream mirror sites will be much easier to use.

iBug avatar Aug 13 '24 19:08 iBug

That would be a great improvement, I'd be happy to review a PR if you're able to pull one together!

segiddins avatar Aug 21 '24 19:08 segiddins

I took a look at the existing code and it seems too entangled for me to handle. I hope someone from Ruby could take on this.

My ideas are:

  • Fetch /versions unconditionally and either:
    • Generate /versions.md5sum file so we (mirror sites) can serve its content as the ETag value for the /versions file, to maintain compatibility with Bundler 2.4.
    • Save the ETag server header to /versions.md5sum which may be even more compatible.
  • For every gem, fetch /info/#{gem.name} if either:
    • The target file is missing.
    • A new version of the gem is being fetched.
  • For every info file, delete it if deletion is enabled and the corresponding gem has gone.

iBug avatar Aug 22 '24 20:08 iBug

@iBug Share one of our practices, which is to redirect the /info/ directory to the official address, so that no matter what package is downloaded and installed, the original metadata will be accessed.

89ao avatar Sep 06 '24 03:09 89ao

According to https://github.com/tuna/issues/issues/2048, a mirror created by gem mirror without additional care is unusable with gem.

iBug avatar Oct 29 '24 11:10 iBug