Nikita Kazakov
Nikita Kazakov
1 min read

Tags

Bottom Line — You’ll need a Ruby version manager if you plan on working with Ruby and Rails.

2020 Update: I don’t use ASDF anymore. I use RVM for Ruby / Rails.

Using a version manager is critical if you plan on running different projects from GitHub. A project might not be compatible with the version of Ruby you have installed.

We need a way to switch between versions of Ruby without installing and uninstalling them every time.

I’ll show you how to switch versions easily using ASDF-VM, a version manager for Ruby and other languages.

Make sure your machine doesn’t have Ruby installed. Let’s install ASDF-VM.

Although ASDF-VM is not the only version manager on the block, I prefer it because it is easy to install and use. Other popular version managers like RVM or RBENV also do the job.

I’m using these instructions to install ASDF-VM below.

Open your terminal and clone the latest ASDF-VM branch.

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.2

Let’s add ASDF-VM to our shell so we can run it from any folder.

echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

To take effect, close your terminal window and reopen it again.  Run:

asdf

You’ll see something like this:

</figure>

ASDF-VM doesn’t have a GUI interface and those are the commands you can run it with.

Let’s install Ruby dependencies before installing Ruby.

sudo apt install build-essential
sudo apt install zlib1g-dev libssl-dev libreadline-dev libgdbm-dev

We want to install the ASDF-VM ruby plugin.

asdf plugin-add ruby

Let’s install Ruby through ASDF-VM.  I want to install Ruby version 2.6.2. Other versions are available depending on what you want to run.

asdf install ruby 2.4.4 

Run ASDF again and see other commands available to manage your Ruby package.

asdf
![](https://paper-attachments.dropbox.com/s_B4F8639630B0FBC36DFABA0ACADCD708C18AE4C40D59D285D20FE9A240094838_1559652951496_image.png)
asdf current

This tells you that no version is set for Ruby on this machine.  To check available versions, run:

asdf list ruby

You’ll see 2.6.2. Let’s set it as the global (screenshot shows local) version to use.

Asdf global ruby 2.6.2

Double check:

asdf current

It should say Ruby 2.6.2. To triple check, go ahead and run the version command on Ruby itself in the terminal.

ruby -v

Ruby 2.6.2 is installed and is active.