2

I tried to install Ruby with version specified 2.5.1 (the version is just example), and tried following script, but I got an error as follows. Is it possible to install Ruby with a version using apt installing so I can deal with Ruby version dependency issue?

$ sudo apt update ; sudo apt install ruby-full=2.5.1
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Get:2 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://ppa.launchpad.net/kelleyk/emacs/ubuntu bionic InRelease                                            
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease       
Hit:6 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease                                              
Hit:7 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease                                            
Hit:8 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease                                               
Hit:9 http://ppa.launchpad.net/teejee2008/timeshift/ubuntu bionic InRelease
Fetched 64.4 kB in 2s (41.9 kB/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
40 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Version '2.5.1' for 'ruby-full' was not found
ー PupSoZeyDe ー
  • 1,082
  • 3
  • 14
  • 33
  • This could be done by this method. Refer this answer [link](https://stackoverflow.com/questions/26595620/how-to-install-ruby-2-1-4-on-ubuntu-14-04) – kaceva5618 Nov 15 '20 at 11:49

2 Answers2

3

You can install rbenv which is a Ruby Environment and then you can install the version of Ruby you want over it.

Refer to this answer.

theWellHopeErr
  • 1,856
  • 7
  • 22
  • 1
    thanks :) I prefer a way not use a additional version management tool if possible. For example in PHP you can use `update-alternatives` rather than phpenv. also, I tried rbenv actually and seemed not compatible with my machine. – ー PupSoZeyDe ー Nov 15 '20 at 11:49
2

The specific version of ruby you want to install has to be a package available in your Ubuntu distro's package repository. A quick way to check this is using apt list | grep ruby-full or apt list | grep ruby.

If you don't find the version you're looking for, you can add a repository and download it from there. Brightbox is a widely used repository maintaining several ruby version packages. Their installation docs should help you.

Note: I still recommend that you use a ruby version manager like rbenv or rvm.

svetha.cvl
  • 824
  • 4
  • 8