Skip to content

Fix definition lookup for ruby-prefixed names like ruby-dev#2621

Merged
eregon merged 1 commit into
rbenv:masterfrom
amatsuda:fix-resolve-version-ruby-prefix
May 3, 2026
Merged

Fix definition lookup for ruby-prefixed names like ruby-dev#2621
eregon merged 1 commit into
rbenv:masterfrom
amatsuda:fix-resolve-version-ruby-prefix

Conversation

@amatsuda
Copy link
Copy Markdown
Contributor

@amatsuda amatsuda commented May 3, 2026

Currently, rbenv install ruby-dev fails as follows since 92d57fd introduced via #2610.

% ruby-build --version
ruby-build 20260501

% rbenv install -f -v ruby-dev
ruby-build: definition not found: ruby-dev

The following versions contain `ruby-dev' in the name:
  jruby-dev
  mruby-dev
  ruby-dev
  truffleruby-dev

See all available versions with `rbenv install --list-all'.

If the version you need is missing, try upgrading ruby-build:

  brew upgrade ruby-build

This patch fixes this regression by trying the exact match first, then falling back to the partial match intruduced via #2610.

`resolve_version` strips the leading `ruby-` from its argument and
then only looks for the stripped form in the definitions directory.
For canonical definitions whose filename retains the `ruby-` prefix
(currently `ruby-dev`) the exact-match step searches for `dev`,
which does not exist, and the grep fallback's `^dev[-.]` anchor
also misses the `ruby-dev` line in the definitions list. Result:
`ruby-build ruby-dev` reports "definition not found" even though
the file is shipped.

Try the original (unstripped) argument first in the exact-match
loop, then fall back to the stripped form. Numeric-version inputs
(`ruby-3.4.9`, `3.4`, `ruby-3.4`) and other implementations
(`mruby-dev`, `jruby-dev`) are unaffected because their existing
code paths still match.

Regression introduced in rbenv#2610.
Copy link
Copy Markdown
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix!

@eregon
Copy link
Copy Markdown
Member

eregon commented May 3, 2026

@mislav I'll merge this now since this is a low-risk bug fix and it fixes a significant released breaking change.
Could you let me know if it's OK if I merge such bug fixes? If not, I'm sorry about that.

@eregon eregon merged commit b0a21cd into rbenv:master May 3, 2026
4 checks passed
@eregon
Copy link
Copy Markdown
Member

eregon commented May 3, 2026

@amatsuda amatsuda deleted the fix-resolve-version-ruby-prefix branch May 3, 2026 22:54
@mislav
Copy link
Copy Markdown
Member

mislav commented May 4, 2026

@amatsuda Thank you!

@eregon Yes it’s perfectly fine to rush fixes for regressions like these; much appreciated.

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.

3 participants