Strip the brew formula revision from detected Homebrew Ruby versions - #136
Merged
Conversation
Homebrew shipped ruby 4.0.6_1 and detect_homebrew_ruby_version returned the keg dirname verbatim - brew's PKG version, whose "_N" revision suffix (a rebuild of the same upstream Ruby) is not part of RUBY_VERSION and is rejected by Gem::Version. Every dev command in an unpinned repo on such a machine died pre-dispatch with "Malformed version number string 4.0.6_1" (first seen: the snappy CI runner the day its brew updated). Detection now extracts only the numeric version prefix from the dirname; anything else still falls through to asking the ruby binary itself. Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
ruby 4.0.6_1, andShadowenvRuby.detect_homebrew_ruby_versionreturns the Cellar keg dirname verbatim — brew's PKG version, whose_Nformula-revision suffix (a rebuild of the same upstream Ruby) is not part ofRUBY_VERSIONand is rejected byGem::Version. Every dev command in a repo without arubypin on such a machine died pre-dispatch withdev: Malformed version number string 4.0.6_1(first seen on the snappy CI runner the day its brew updated).4.0.6_1→4.0.6); anything that doesn't look like a version still falls through to asking the ruby binary directly, as before.Test-first: the revision-keg scenario was red before the fix (real temp Cellar dirs,
brew_prefix_formocked as the boundary), plus a passthrough test pinning the plain-keg behavior.Test plan
dev test— 934 tests, 0 failures (the new revision test red before, green after)dev style— no offensesdev tc— cleanMade with Cursor