Simple solution (directly installs latest stable version):

rbenv install $(rbenv install -l | grep -v - | tail -1)

Explanation:

rbenv install -l | grep -v - | tail -1

Filters out all versions that contain a hyphen -, which is all non-MRI versions and prerelease MRI versions. Then selects the last one, guaranteed to be the highest because ruby-build output is already sorted by version number ascending.

Answer from mislav on Stack Overflow
🌐
GitHub
github.com › rbenv › rbenv
GitHub - rbenv/rbenv: Manage your app's Ruby environment · GitHub
The rbenv install command does not ship with rbenv out-of-the-box, but is provided by the ruby-build plugin. Before attempting to install Ruby, check that your build environment has the necessary tools and libraries. Then: # list latest stable versions: rbenv install -l # list all local versions: rbenv install -L # install a Ruby version: rbenv install 3.1.2
Starred by 16.7K users
Forked by 1.4K users
Languages   Shell 97.8% | Ruby 1.6%
Discussions

rbenv not showing the available ruby versions - Stack Overflow
Currently only rbenv install --list-all will show all versions available for installation 2021-12-22T21:08:16.357Z+00:00 ... If you have tried both rbenv install --list and ruby-build --definitions and still can't see the latest Ruby versions on the list, then you need to upgrade ruby-build ... More on stackoverflow.com
🌐 stackoverflow.com
Need to install Ruby 2.7.7 with rbenv but rbenv doesn't list it. Help?
It seem you have outdated ruby-build. Try updating homebrew and upgrading ruby-build More on reddit.com
🌐 r/ruby
5
6
February 1, 2023
How can I install an Rbenv version specified by a .ruby-version file
the command to install that specific version is rbenv install More on reddit.com
🌐 r/ruby
6
8
March 23, 2020
Can't install latest Ruby on OS Sonoma due to 'no permissions'
Make sure you have `rbenv` activated in your shell (`rbenv init`). It sounds like you might be missing the piece that goes in your `.zshrc` file? More on reddit.com
🌐 r/ruby
5
4
June 14, 2024
🌐
GitHub
github.com › rbenv › rbenv › releases
Releases · rbenv/rbenv
Added rbenv --version for printing the current version of rbenv.
Author   rbenv
🌐
Homebrew
formulae.brew.sh › formula › rbenv
rbenv — Homebrew Formulae
brew install rbenv · Ruby version manager · https://rbenv.org · License: MIT · Development: Pull requests · Formula JSON API: /api/formula/rbenv.json · Formula code: rbenv.rb on GitHub · Bottle (binary package) installation support provided.
🌐
Ruby Programming Language
ruby-lang.org › en › downloads
Download Ruby | Ruby
Here you can get the latest Ruby distributions in your favorite flavor. The current stable version is 4.0.4. Please be sure to read Ruby’s License. We have several tools on each major platform to install Ruby: On Linux/UNIX, you can use the ...
🌐
Better Stack
betterstack.com › community › guides › scaling-ruby › rbenv-explained
Getting Started with rbenv | Better Stack Community
September 30, 2025 - At the time of writing, Ruby 3.4.6 represents the current stable release: ... The installation process downloads the Ruby source code, compiles it with optimizations for your system, and installs it in rbenv's version directory.
🌐
Rbenv
rbenv.org
rbenv - the Ruby version manager
It is useful for switching between multiple Ruby versions on the same machine and for ensuring that each project you are working on always runs on the correct Ruby version. ... To install rbenv and ruby-build on a system with either Homebrew or git, paste this into your terminal:
Find elsewhere
🌐
Devhints
devhints.io › ruby › rbenv cheatsheet
rbenv cheatsheet
These are generic instructions; there may be rbenv packages available for your OS. ... Application-specific version numbers are stored in .ruby-version.
🌐
DEV Community
dev.to › sarahcssiqueira › managing-ruby-versions-on-macos-apple-silicon-with-rbenv-1mon
Managing Ruby versions on macOS Apple Silicon with rbenv - DEV Community
September 14, 2024 - To set this newly installed Ruby version as the global default, run: ... And that's it! You have successfully updated Ruby on your macOS system using rbenv.
🌐
Javierjulio
javierjulio.com › rbenv
rbenv - Simple Ruby Version Management - Javier Julio
You should do this any time you install a new Ruby binary (for example, when installing a new Ruby version, or when installing a gem that provides a binary). ... If you've installed rbenv using the instructions above, you can upgrade your installation at any time using git. To upgrade to the latest development version of rbenv, use git pull:
🌐
Rbenv
rbenv.org › man › rbenv.1
rbenv(1) Manual Page
June 21, 2023 - The most common plugin for rbenv is ruby-build which facilitates installing new Ruby versions into the $RBENV_ROOT/versions directory.
🌐
Richstone
richstone.io › where-is-ruby-3-0-0-on-rbenv
https://richstone.io/where-is-ruby-3-0-0-on-rbenv/
January 7, 2023 - -> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz Installing ruby-3.0.0... ... ⏲⏲⏲ ... ... ⏲⏲⏲ ... ... ⏲⏲⏲ ... Installed ruby-3.0.0 to ~/.rbenv/versions/3.0.0 ... And for the sake of completeness and inclusiveness, let's see how it's done on the other operating that exists in this world: If you installed rbenv via homebrew you'll need to do brew upgrade which will also update your rbenv so that latest stable versions of Ruby should appear in your rbenv.
🌐
Bitnami
docs.bitnami.com › aws › infrastructure › ruby › get-started › understand-rbenv
Get started with rbenv - Bitnami Documentation
February 6, 2026 - To list the installed Ruby versions in your machine with rbenv, run the following command:
🌐
Karloespiritu
karloespiritu.github.io › cheatsheets › rbenv
rbenv · Cheatsheets
# Install rbenv $ brew install ... version of Ruby to be used in all shells # by writing the version name to the `~/.rbenv/version` file $ rbenv global 2.2.1 # Sets a shell-specific Ruby version by setting the # RBENV_VERSION environment variable in your shel...
🌐
Medium
medium.com › @norton.seanm › a-guide-to-using-rbenv-mac-4ca211b1c713
A Guide to using rbenv (Mac). Your ruby environment should be a… | by Sean Norton | Medium
April 22, 2019 - You will use this command to set the local version, replacing the version with the one you want and have already installed. ... Note: the same commands except for --unset work for global, by using $ rbenv global ... To upgrade to the latest rbenv and update ruby-build with newly released Ruby ...
🌐
GitHub
github.com › rbenv › ruby-build › discussions › 2198
How to decide what version to install from <rbenv install -l> · rbenv/ruby-build · Discussion #2198
May 31, 2023 - I have followed https://github.com/rbenv/rbenv page, installing it on Ubuntu (latest version).
Author   rbenv
🌐
Reddit
reddit.com › r/ruby › need to install ruby 2.7.7 with rbenv but rbenv doesn't list it. help?
r/ruby on Reddit: Need to install Ruby 2.7.7 with rbenv but rbenv doesn't list it. Help?
February 1, 2023 -

The why:

  • A Rails app stuck on Rails 4 (which I don't think supports Ruby 3.x)

  • Heroku-18 stack EOL approaching

  • Heroku-20 supports Ruby 2.7.7

  • Trying to extend the maintainability window of the app by moving it to Heroku-20 stack - while working on upgrading the app.

But, rbenv --list-all does not list 2.7.7 - the mri rubies list stops at 2.7.5 (as of Feb 1 2023).

rbenv on M1 hardware.

How can I install 2.7.7 via rbenv?

🌐
Toshima
blog.toshima.ru › 2021 › 08 › 08 › rbenv-commands.html
[rbenv] List installed/stable/available versions | Toshimaru’s Blog
August 7, 2021 - $ rbenv install -l 2.6.8 2.7.4 3.0.2 jruby-9.2.19.0 mruby-3.0.0 rbx-5.0 truffleruby-21.2.0 truffleruby+graalvm-21.2.0 Only latest stable releases for each Ruby implementation are shown. Use 'rbenv install --list-all / -L' to show all local versions.