How To Install Ruby 3 With rbenv?

Rich Steinmetz
How To Install Ruby 3 With rbenv?

Naive as I am, I fired up my terminal and gave it a spontaneous shot:

~ rbenv install 3.0.0
ruby-build: definition not found: 3.0.0

See all available versions with `rbenv install --list'.
~
~ # so the investigation began: 🔎🔎🔎
~
~ rbenv install --list
2.5.8
2.6.6
2.7.1
jruby-9.2.13.0
maglev-1.0.0
mruby-2.1.2
rbx-5.0
truffleruby-20.2.0
truffleruby+graalvm-20.2.0
~
~ # WTF?! truffle 20!?!?
A naive shot.

You will most probably encounter this issue when you have rbenv lying around for quite a while already. So the investigation continued:

Where's Ruby 3 in rbenv? 🤔 🔎

rbenv install Ruby 3 on Ubuntu

The sad truth is that my brain was not willing to read the whole terminal output which already poses the solution:

❯ rbenv install 3.0.0
ruby-build: definition not found: 3.0.0

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

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

  git -C ~/.rbenv/plugins/ruby-build pull
~
~ # here we go, the crucial hint at the end of the output!
~
~ git -C ~/.rbenv/plugins/ruby-build pull
remote: Enumerating objects: 254, done.
remote: Counting objects: 100% (254/254), done.
remote: Compressing objects: 100% (22/22), done.
...
~
~ rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> 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
~
~ rbenv versions
  2.6.6
* 2.7.1 (set by ~/.rbenv/version)
  3.0.0 🎊🎊🎊
The one moment when "being aware" actually does something.

And for the sake of completeness and inclusiveness:

rbenv install Ruby 3 on MacOS

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.

If you are not using homebrew I don't know what you are doing, and most probably you know what you are doing (but then, why are you here?).

$ cd /humus
$ mkdir juhu


Join the conversation.

Great! Check your inbox and click the link
Great! Next, complete checkout for full access to Rich Stone Input Output
Welcome back! You've successfully signed in
You've successfully subscribed to Rich Stone Input Output
Success! Your account is fully activated, you now have access to all content
Success! Your billing info has been updated
Your billing was not updated