How to update your rbenv ruby version

When you install rbenv with git to your machine, it does not update automatically all the new available ruby versions. Therefore, you need to update by git pulling the latest stable release. This minipost will demonstrate step-by-step how to configure your rbenv with the latest stable release of Ruby.

Navigate to ruby downloads and find out the latest stable release that is available for installation. At this point in time, the latest stable release of Ruby is 2.6.1

Ruby 2.6.1
sha256: 17024fb7bb203d9cf7a5a42c78ff6ce77140f9d083676044a7db67f1e5191cb8

In order to list all the already installed ruby versions, type:

$ rbenv versions
* 2.6.0 (set by /home/dev/.rbenv/version)

To list all the available versions for installation you have locally, type:

$ rbenv install -l

The list is pretty long, I have omitted many versions for brevity using [..]. With only the list command is hard for you to see if you have the specific version of Ruby you are looking for. Therefore, grep the listing with a specific version:

$ rbenv install -l | grep 2.6.1

The above returns nothing. You need to get the Ruby 2.6.1 locally, to achieve this, type:

$ cd ~/.rbenv/plugins/ruby-build/ && git pull

The git pull output, should be similar to the following:

create mode 100644 share/ruby-build/2.6.1
create mode 100644 share/ruby-build/2.7.0-dev

List the available versions and grep for 2.6.1 by:

$ rbenv install -l | grep 2.6.1

Install ruby version 2.6.1, type:

$ rbenv install 2.6.1
Downloading ruby-2.6.1.tar.bz2...
Installing ruby-2.6.1...
Installed ruby-2.6.1 to /home/dev/.rbenv/versions/2.6.1

You have now successfully installed the latest ruby version, setup that version to be the global ruby version of the system, by:

$ rbenv global 2.6.1

Now you have to rehash rbenv in order to install shims for all Ruby executables known to rbenv. Run the following command:

$ rbenv rehash

Finally, check the ruby version, type:

$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]

From now on, the default / global ruby version will be ruby 2.6.1p33.

Additional information:

Buy Me A Coffee

Read also the following