* 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>
Depending on bash version, the expression `${var/$HOME\//~/}` will not have
effect because the "~" character in the replacement expression is expanded.
The updated approach is a bit of a mouthful, but it avoids using "~" in a
substitution pattern, while also guarding against values of HOME that are
blank or when HOME is literally just "/".
Currently, this test fails if .git isn't present as it expects a
Git-specific output. This change temporarily creates a ".git"
directory during the test run to simulate the existence of a git
repository, thus keeping `rbenv install` output stable.
Co-authored-by: Mislav Marohnić <git@mislav.net>
Upon installing their first Ruby version on the system, the user may want to set it as their default; otherwise the default will remain "system" and any `gem install` attempts will fail with a permission error.
This suggestion is skipped if the user already has chosen an explicit default, even if it's "system".
Bats doesn't support both suite-wide setup (in helper) *and* file-wide
setup. Which means the existance of any file-level setup() function
overwrites any setup() function from test_helper. This can be confusing,
and (IMO) easier to simply avoid the overwriting and remove any
_implied_ suite-wide setup function from test_helper.
This turns out to not be so bad for the recently added setup function,
because the only test files that actually need aria2c removed from PATH
are those that actually invoke curl. These can be found because they are
the only test files that stub curl; half of which already had
file-specific setup() functions. So the only ones which need a
file-local setup() function added were: checksum.bats and mirror.bats
Along these lines, rbenv.bats and hooks.bats were removing aria2c from
PATH but don't actually need to. (curl isn't stubbed in these tests so
the existance of aria2c wouldn't affect the tests)
Lastly, fixed a tab/spaces whitespace mixup that was introduced by:
750c086d11
When a target is not found, rbenv-install proposes pulling changes from
upstream. This involves changing the directory to the ruby-build checkout.
This patch adds a '&& cd -' to change the working directory back to where
we've been. Should work on at least Bash and Zsh.
Because ruby-build is both a Homebrew formula and an rbenv plugin, some
people end up with both installed. In these cases, executing
`rbenv install` vs. `ruby-build` might not use the same install. Users
end up being unsure where `rbenv install` is coming from and upgrading
it from the wrong location.
This detect whether ruby-build is contained in Homebrew or git and shows
upgrade instructions accordingly. Example:
See all available versions with \`rbenv install --list'.
If the version you need is missing, try upgrading ruby-build:
brew update && brew upgrade ruby-build
The build definitions auto-discovered from rbenv plugins would
previously not appear in `--list` results due to discovery process
taking place too late.