Why can't rbenv install the latest Ruby version on Ubuntu?
Asked Answered
S

2

12

I want to install a recent version of Ruby on Ubuntu 20.04. But when I run rbenv install -l on my Ubuntu server, I only see old versions of Ruby listed.

Available versions:
  1.8.5-p52
  ...
  2.2.7
  2.3.0-dev
  2.3.0-preview1
  2.3.0-preview2
  2.3.0
  2.3.1
  2.3.2
  2.3.3
  2.3.4
  2.4.0-dev
  2.4.0-preview1
  2.4.0-preview2
  2.4.0-preview3
  2.4.0-rc1
  2.4.0
  2.4.1
  2.5.0-dev
  jruby-1.5.6
  jruby-1.6.3
  jruby-1.6.4
  ...
  jruby-9.1.8.0
  jruby-9.1.9.0-dev
  jruby-9.1.9.0
  jruby-9.1.10.0
  jruby-9.1.11.0
  jruby-9.1.12.0
  maglev-1.0.0
  maglev-1.1.0-dev
  maglev-2.0.0-dev
  mruby-dev
  mruby-1.0.0
  mruby-1.1.0
  mruby-1.2.0
  rbx-2.2.2
  rbx-2.2.3
  ...
  rbx-3.79
  rbx-3.80
  rbx-3.81
  rbx-3.82
  ree-1.8.7-2011.03
  ree-1.8.7-2011.12
  ree-1.8.7-2012.01
  ree-1.8.7-2012.02
  topaz-dev

Compared to when I run it locally on my mac, I see recent versions like 2.7.1.

2.5.8
2.6.6
2.7.1
...

Why don't these new version show on Ubuntu? I have rbenv 1.1.1 installed on Ubuntu.

This is probably a dumb question but I have little understanding of code below the webdev level.

Sinker answered 16/11, 2020 at 15:35 Comment(0)
S
24

I ran this command and it solved my problem.

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Now I see recent versions of Ruby.

Sinker answered 16/11, 2020 at 15:37 Comment(0)
M
1

The reason is rbenv uses ruby-build and your Ubuntu ships a relatively old ruby-build version. Even Ubuntu 24.04 ships this 2 year old release of ruby-build 20220426-1 which does not include the latest ruby versions.

You can upgrade your system ruby-build (but the packages seem a bit behind) or just like you did clone the git repo as a plugin into your rbenv directory: git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

However, you will need to keep your ruby-build clone up to date if you want to keep up with new ruby releases: git -C "$(rbenv root)"/plugins/ruby-build pull

Murmuration answered 1/5, 2024 at 22:38 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.