Commit graph

18 commits

Author SHA1 Message Date
Akira Matsuda
e98dffb562
Fix definition lookup for ruby-prefixed names like ruby-dev
`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 #2610.
2026-05-03 22:16:26 +09:00
Jean Boussier
92d57fdbb6
Support building with version prefix (#2610)
* Support building with version prefix

Commonly in CI pipelines and other scripts, users may
want to install the latest from a specific series, e.g.
`3.4` or `jruby-10.0`.

```bash
$ bin/ruby-build 3.4 /tmp/3.4
...
Downloading ruby-3.4.9.tar.gz...

$ bin/ruby-build 4.0 /tmp/4.0
...
Downloading ruby-4.0.2.tar.gz...
```

Also support `--resolve`:

```bash
$ bin/ruby-build --resolve 3.4
3.4.9
```

* Improve version name resolution from prefix

- `ruby-build --resolve` now prints canonical definition names, always
  stripping the "ruby-" prefix from output (e.g. "ruby-3.4" => "3.4.9").

- Fix sorting versions so that "jruby" correctly resolves to "jruby-10.x"
  instead of to "jruby-9.x".

- Support bare "ruby" argument to select the latest CRuby version, since
  that was already possible for "jruby", "mruby", et al.

- Case-normalize version inputs so that arguments like "JRuby" or
  "TruffleRuby" resolve to their lowercase definitions.

- Simplify definition file lookup: all code paths now go through
  resolve_version.

- Restore the named-pipe + `--dir` check to correctly abort early.

- Update README and man page: bump Ruby version numbers in examples, add
  Ruby implementations section, document the `--resolve` option.

* Clarify what ruby-build considers to be "latest" Ruby version

* Print usage error message if `--resolve` wasn't passed an argument

---------

Co-authored-by: Mislav Marohnić <git@mislav.net>
2026-05-01 12:25:11 +02:00
Benoit Daloze
30895f03c4 Rename definition to truffleruby+graalvm
* '+' needs to be considered part of the name for --definitions and -l
  to see truffleruby and truffleruby+graalvm as separate.
2020-07-22 16:41:01 +02:00
Benoit Daloze
767a1ccc30 Add support for installing GraalVM
* Supports using other GraalVM languages such as JavaScript, Python, R and Java.
* Supports running TruffleRuby on JVM and not only Native.
* Add GraalVM 20.1.0.
2020-07-22 16:41:01 +02:00
Koichiro Iwao
e2b65f5dd5 Merge branch 'master' into list-exclude-eol 2020-04-27 11:20:31 +09:00
Koichiro Iwao
c76bf6fb80
s/all available definitions/all local definitions/
"available" implies ruby-build will be checking online sources but
actually ruby-build doesn't do that. "local definitions" may be
prefered.

Pointed out by jasonkarns.
2020-03-20 18:08:04 +09:00
Koichiro Iwao
66647e3953
s/all built-in definitions/all available definitions/
Suggested by mislav: https://github.com/rbenv/ruby-build/pull/1402#discussion_r389060742

> I wonder should we substitute "built-in" with something like "all
> available definitions". Since ruby-build will additionally pick up
> definitions found under the paths listed in RUBY_BUILD_DEFINITIONS,
> these definitions will get listed even if they are not "built-in".
> Therefore, "built-in" feels like a misnomer here.
2020-03-19 18:16:16 +09:00
Koichiro Iwao
67ac0b45d6
the short list now shows only latest stable versions
for each Ruby implementations like the following.

    2.4.9
    2.5.7
    2.6.5
    2.7.0
    jruby-9.2.9.0
    maglev-1.0.0
    mruby-2.1.0
    rbx-3.107
    truffleruby-19.3.1
2020-03-06 22:23:46 +09:00
Benoit Daloze
08af628396 Add a few extra examples for the version sorting test 2019-11-21 16:41:12 +01:00
Benoit Daloze
a8a3ebf809 Add tests for TruffleRuby 2018-06-15 20:17:13 +02:00
Ivan Kuchin
cb84607d3e fix ordering for versions with different length patch number (nothing, p72, p375) 2017-02-25 15:48:03 +01:00
Ivan Kuchin
e35d7a59ab remove quotes preventing from iterating over each version in sort versions test 2017-02-25 15:48:03 +01:00
Jason Karns
84b49768b9 Add refute test helper 2016-01-20 10:43:46 -05:00
Mislav Marohnić
ffcb7ed67f Add test that ensures duplicate Ruby definitions don't get displayed 2014-10-28 19:30:01 +01:00
Mislav Marohnić
323c2b778b Sort Ruby versions when listing available definitions
Stable releases should now be sorted as a higher version than preview
releases or RCs. For instance:

- 1.9.3-preview < 1.9.3-rc1 < 1.9.3-p0
- 2.1.0-dev < 2.1.0-rc1 < 2.1.0
- jruby-1.7.0-preview1 < jruby-1.7.0-rc1 < jruby-1.7.0
2014-09-08 13:06:48 -07:00
Mislav Marohnić
f118b173af Extra definitions paths via RUBY_BUILD_DEFINITIONS
This is a colon-separated list of directories that will get searched for
build definition in order from left to right.
2014-08-17 12:20:53 -07:00
Mislav Marohnić
ff75ca7204 Support changing RUBY_BUILD_ROOT
This is to allow specifying an alternate path where `share/ruby-build/*`
definitions reside. Useful in tests as well.
2014-08-17 12:20:53 -07:00
Mislav Marohnić
4e2177d5c2 Add test for ruby-build definitions 2014-08-16 19:56:40 -07:00