Skip to content

Strip the brew formula revision from detected Homebrew Ruby versions - #136

Merged
JPDuchesne merged 1 commit into
mainfrom
fix/brew-ruby-revision-suffix
Aug 27, 2026
Merged

Strip the brew formula revision from detected Homebrew Ruby versions#136
JPDuchesne merged 1 commit into
mainfrom
fix/brew-ruby-revision-suffix

Conversation

@JPDuchesne

Copy link
Copy Markdown
Contributor

Summary

  • Homebrew shipped ruby 4.0.6_1, and ShadowenvRuby.detect_homebrew_ruby_version returns the Cellar keg dirname verbatim — brew's PKG version, whose _N formula-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 a repo without a ruby pin on such a machine died pre-dispatch with dev: Malformed version number string 4.0.6_1 (first seen on the snappy CI runner the day its brew updated).
  • Detection now extracts only the numeric version prefix from the dirname (4.0.6_14.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_for mocked 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 offenses
  • dev tc — clean

Made with Cursor

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

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@JPDuchesne
JPDuchesne merged commit c46b092 into main Aug 27, 2026
5 checks passed
@JPDuchesne
JPDuchesne deleted the fix/brew-ruby-revision-suffix branch August 27, 2026 01:19
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