Skip to content

Decode content-addressed gem metadata in remote CLI output - #175

Draft
girachawda wants to merge 1 commit into
ho/local-rubygems-installation-cafrom
gc/ca-cli-command-cleanup
Draft

Decode content-addressed gem metadata in remote CLI output#175
girachawda wants to merge 1 commit into
ho/local-rubygems-installation-cafrom
gc/ca-cli-command-cleanup

Conversation

@girachawda

@girachawda girachawda commented Aug 5, 2026

Copy link
Copy Markdown

TL;DR

Cleans up remote CLI output for content-addressed gems so gem list -r, gem search -r, and gem info -r display the real platform and Ruby ABI instead of the content-address hash.

Addresses: ruby#9729

This is stacked on ho/local-rubygems-installation-ca to keep the diff focused on this issue while the CA dependency chain lands.

Description

Compact-index entries for skinny/content-addressed gems use the content address as the version suffix, while the real platform and Ruby ABI live in compact-index requirements. Before this change, the remote query path treated the suffix as the platform, so CLI output could show a hash where users expect a platform.

This change:

  • Detects content-address suffixes while loading compact-index specs.
  • Reads the matching compact-index info row to decode platform: and ruby: metadata.
  • Carries content_address and ruby_abi on Gem::NameTuple.
  • Keeps SHA-based full names internally for gemspec fetching.
  • Displays real platforms and Ruby ABI values in gem list -r, gem search -r, and gem info -r.
  • Keeps multiple skinny variants with the same version/platform distinct when their Ruby ABI differs.

Testing

ruby --disable-gems -Ilib:test test/rubygems/test_gem_source.rb
ruby --disable-gems -Ilib:test test/rubygems/test_gem_commands_list_command.rb
ruby --disable-gems -Ilib:test test/rubygems/test_gem_commands_search_command.rb
ruby --disable-gems -Ilib:test test/rubygems/test_gem_commands_info_command.rb
ruby --disable-gems -Ilib:test test/rubygems/test_gem_name_tuple.rb

Manual tophat

Run this from the repo root. It starts a tiny local compact-index server with two skinny variants for the same gem/version/platform, then checks gem list -r, gem search -r, and gem info -r.

cd /Users/girachawda/src/github.com/Shopify/rubygems

TMPDIR_CA=$(mktemp -d)
GEMHOME_CA=$(mktemp -d)
PORT_CA=$(ruby -rsocket -e 's = TCPServer.new("127.0.0.1", 0); print s.addr[1]; s.close')
MARSHAL_VERSION=$(ruby --disable-gems -Ilib -e 'require "rubygems"; print Gem.marshal_version')

mkdir -p "$TMPDIR_CA/info" "$TMPDIR_CA/quick/Marshal.$MARSHAL_VERSION"

printf 'created_at: 2026-01-01T00:00:00Z\n---\na 1-abcdef12,1-fedcba98 0000\n' > "$TMPDIR_CA/versions"

printf -- '---\n1-abcdef12 |checksum:123,ruby:~> 3.3.0,platform:= x86_64-linux\n1-fedcba98 |checksum:456,ruby:~> 3.4.0,platform:= x86_64-linux\n' > "$TMPDIR_CA/info/a"

ruby --disable-gems -Ilib -rzlib -e 'require "rubygems"; address = ARGV.fetch(0); abi = ARGV.fetch(1); spec = Gem::Specification.new("a", "1"); spec.platform = "x86_64-linux"; spec.content_address = address; spec.summary = "manual tophat summary for ruby #{abi}"; spec.homepage = "http://example.com"; spec.authors = ["Tophat User"]; print Zlib::Deflate.deflate(Marshal.dump(spec))' abcdef12 3.3 > "$TMPDIR_CA/quick/Marshal.$MARSHAL_VERSION/a-1-abcdef12.gemspec.rz"

ruby --disable-gems -Ilib -rzlib -e 'require "rubygems"; address = ARGV.fetch(0); abi = ARGV.fetch(1); spec = Gem::Specification.new("a", "1"); spec.platform = "x86_64-linux"; spec.content_address = address; spec.summary = "manual tophat summary for ruby #{abi}"; spec.homepage = "http://example.com"; spec.authors = ["Tophat User"]; print Zlib::Deflate.deflate(Marshal.dump(spec))' fedcba98 3.4 > "$TMPDIR_CA/quick/Marshal.$MARSHAL_VERSION/a-1-fedcba98.gemspec.rz"

python3 -m http.server "$PORT_CA" --bind 127.0.0.1 --directory "$TMPDIR_CA" >/tmp/rubygems-ca-tophat.log 2>&1 &
SERVER_PID=$!

SOURCE_CA="http://127.0.0.1:$PORT_CA"
export GEM_HOME="$GEMHOME_CA"
export GEM_PATH="$GEMHOME_CA"

ruby --disable-gems -Ilib exe/gem list a -r --clear-sources --source "$SOURCE_CA"
ruby --disable-gems -Ilib exe/gem search a -r --clear-sources --source "$SOURCE_CA"
ruby --disable-gems -Ilib exe/gem info a -r --clear-sources --source "$SOURCE_CA"

kill "$SERVER_PID"
rm -rf "$TMPDIR_CA" "$GEMHOME_CA"

Expected output:

a (1 x86_64-linux ruby-abi:3.3 ruby-abi:3.4)
a (1 x86_64-linux ruby-abi:3.3 ruby-abi:3.4)
a (1)
    Platform: x86_64-linux
    Ruby ABIs: 3.3, 3.4
    Author: Tophat User
    Homepage: http://example.com

    manual tophat summary for ruby 3.4

The content-address hashes (abcdef12, fedcba98) should not be displayed in CLI output.

@girachawda
girachawda marked this pull request as draft August 5, 2026 22:28
Assisted-By: devx/522782f7-d29c-46ab-91ec-cfc2d2e7e59a
@girachawda
girachawda force-pushed the gc/ca-cli-command-cleanup branch from ebc9dd7 to 10b3b19 Compare August 6, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant