How I build and install specific versions of ruby

Posted on December 31, 2018

How I build and install specific versions of ruby

First, I use ruby-build.

Install ruby-build

Dependencies:

sudo apt-get install -y libreadline-dev

Download the source:

ᐅ git clone https://github.com/rbenv/ruby-build.git
Cloning into 'ruby-build'...
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 9620 (delta 9), reused 23 (delta 4), pack-reused 9591
Receiving objects: 100% (9620/9620), 2.03 MiB | 225.00 KiB/s, done.
Resolving deltas: 100% (6275/6275), done.
Checking connectivity... done.

Run the install script

ᐅ PREFIX=/usr/local sudo ./ruby-build/install.sh

Now we can install a specific version of ruby..

Got a project that needs some 2.3.x? Let’s build 2.3.0!

ᐅ ruby-build 2.3.0 ~/local/ruby-2.3.0
Downloading ruby-2.3.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.bz2
Installing ruby-2.3.0...
Installed ruby-2.3.0 to /home/user/local/ruby-2.3.0