Allow gem push to select content-addressable gems by platform and Ruby ABI - #174
Open
girachawda wants to merge 7 commits into
Open
Allow gem push to select content-addressable gems by platform and Ruby ABI#174girachawda wants to merge 7 commits into
girachawda wants to merge 7 commits into
Conversation
girachawda
marked this pull request as draft
August 4, 2026 23:03
girachawda
force-pushed
the
gc/ca-gem-push
branch
from
August 5, 2026 20:58
f2fc359 to
180a8b3
Compare
girachawda
marked this pull request as ready for review
August 5, 2026 21:00
jenshenny
force-pushed
the
ho/ca-changes-gem-build
branch
4 times, most recently
from
August 6, 2026 21:16
7d030f2 to
8efebaf
Compare
…by_abi from required_ruby_version
…sable or standard)
… the --ruby_abi flag to gem build Assisted-By: devx/9a9728d9-8128-4a99-9993-fe35c4eefb45
Validate the requested Ruby ABI without mutating the spec, then build using a dup of the spec with the derived required_ruby_version applied. The original spec is only updated once the build has succeeded, so a failed build no longer leaves the passed-in spec permanently modified.
jenshenny
force-pushed
the
ho/ca-changes-gem-build
branch
from
August 7, 2026 01:11
8efebaf to
36d68df
Compare
girachawda
force-pushed
the
gc/ca-gem-push
branch
from
August 7, 2026 16:49
180a8b3 to
dacc341
Compare
Assisted-By: devx/6563d395-3a93-455c-8523-fe2052782e76
Assisted-By: devx/6563d395-3a93-455c-8523-fe2052782e76
girachawda
force-pushed
the
gc/ca-gem-push
branch
from
August 7, 2026 16:57
dacc341 to
6ecd136
Compare
jenshenny
force-pushed
the
ho/ca-changes-gem-build
branch
from
August 7, 2026 17:36
36d68df to
8e4d2d1
Compare
jenshenny
reviewed
Aug 7, 2026
jenshenny
left a comment
There was a problem hiding this comment.
Looks good! I put a few comments to make sure we have some edge cases covered.
|
|
||
| def resolve_gem_name(names) | ||
| candidates = names.map do |name| | ||
| [name, Gem::Package.new(name).spec] |
There was a problem hiding this comment.
Gem::Package.new(name).spec could raise a Gem::Package::FormatError and output a confusing error
ERROR: While executing gem ... (Gem::Package::FormatError)
package metadata is missing in demo-0.1.0-662574271f.gem
could we rescue these errors and skip them? eg. alert_warning "Skipping #{name}: #{e.message}".
| suggestions << "Specify --ruby-abi with one of: #{ruby_abis.join(", ")}" unless ruby_abis.empty? | ||
| suggestions << "To push a gem without a Ruby ABI, pass the exact filename." if matches.any? {|_, spec| spec.ruby_abi.nil? } | ||
| suggestions.join("\n") unless suggestions.empty? | ||
| elsif options[:ruby_abi] && !options[:platform] |
There was a problem hiding this comment.
Ruby ABI isn't being validated, could we use validate_ruby_abi to verify the Ruby ABI before filtering?
Comment on lines
+124
to
+131
| case matches.length | ||
| when 1 | ||
| matches.first.first | ||
| when 0 | ||
| raise Gem::CommandLineError, "No gem matched #{gem_name_selector_description}" | ||
| else | ||
| raise Gem::CommandLineError, multiple_matches_message(matches) | ||
| end |
There was a problem hiding this comment.
nit: stylistic preference to make the error cases more readable
Suggested change
| case matches.length | |
| when 1 | |
| matches.first.first | |
| when 0 | |
| raise Gem::CommandLineError, "No gem matched #{gem_name_selector_description}" | |
| else | |
| raise Gem::CommandLineError, multiple_matches_message(matches) | |
| end | |
| raise Gem::CommandLineError, "No gem matched #{gem_name_selector_description}" if matches.empty? | |
| raise Gem::CommandLineError, multiple_matches_message(matches) if matches.length > 1 | |
| gem_name, _spec = matches.first |
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
This PR updates
gem pushso maintainers can select a local gem file by its internal metadata instead of only by filename. This is for the case in which a maintainer may build multiple content-addressed skinny binaries for the same gem version/platform, butgem pushstill pushes one gem at a time. This lets them select the one target they want to push by platform/Ruby ABI instead of manually mapping hashes back to gem metadata.It adds two selector options:
--platform PLATFORM--ruby-abi RUBY_ABIWhen either selector is provided,
gem pushcan accept multiple candidate.gemfiles, inspect each file’s internal gemspec, and push the single file that matches the requested platform and/or Ruby ABI.This PR is stacked on #171, which adds content-addressable gem build support.
Why
Content-addressable skinny gems use hash-based filenames, for example:
From the filename alone, a maintainer cannot tell which file is for Ruby ABI
3.3vs3.4.A maintainer may build multiple skinny gems for the same gem version and platform:
With this PR, they can run:
gem push demo-*.gem --platform arm64-darwin --ruby-abi 3.4and RubyGems will select the matching
.gemfile by reading its internal spec.If no file matches, or if multiple files match,
gem pushraises an error instead of guessing.For ambiguous matches, this PR keeps
gem pushscoped to one final file and makes the error actionable. For example, if--platform arm64-darwinmatches both fat and skinny gems, the error suggests adding--ruby-abito select a skinny gem, or passing the exact filename to push the fat gem.Manual tophat
See Code
--platform arm64-darwin --ruby-abi 3.4selects the matching skinny gem.--platform arm64-darwinwith fat + skinny candidates errors and suggests--ruby-abior exact filename.--platform arm64-darwinwith multiple skinny ABIs errors and suggests available--ruby-abivalues.--ruby-abi 3.4with multiple platforms errors and suggests available--platformvalues.