Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install version specified Ruby using apt

Tags:

ruby

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
like image 799
ー PupSoZeyDe ー Avatar asked Sep 05 '25 03:09

ー PupSoZeyDe ー


2 Answers

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.

like image 65
svetha.cvl Avatar answered Sep 08 '25 22:09

svetha.cvl


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.

like image 45
theWellHopeErr Avatar answered Sep 08 '25 21:09

theWellHopeErr