...

/

Introduction to the Version Management

Introduction to the Version Management

Learn what is RVM and how to use it in your shell.

What is Ruby Version Manager (RVM)

This chapter is essential for Ruby beginners. Now that we know how Ruby works and have done many exercises, we can practice by setting up some valuable tools.

RVM is a thin layer for our shell or IDE. Every programmer often runs the Ruby application with ruby app.rb, but where does the actual ruby come from? Let’s look at the which command output when RVM isn’t installed:

$ which ruby
/usr/bin/ruby

So, the Ruby programming language is just a binary executable file located at /usr/bin/ruby. Here is what it looks like when we open it with Far Manager:

If we delete the file, we won’t be able to run Ruby programs. But how does the shell know that we need to start Ruby from the /usr/bin directory? Let’s look at the $PATH environment variable for our shell (our output can be slightly different):

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

The $PATH variable has multiple directories, separated by a : (colon):

  • /usr/local/bin
  • /usr/bin (where ruby is actually located)
  • /bin
  • /usr/sbin
  • /sbin When we type the ruby command, our shell tries to find the file in the first directory. If the file isn’t found, it iterates over the subsequent directories until it locates it. We can redefine this variable in such a way that the shell looks up the file somewhere else first. We need to prepend the new directory to the $PATH, not append. So, where should we do that?

All shells (Bash, Zsh, etc.) keep their settings in the home directory. We can find our home directory by typing echo $HOME or echo ~. Bash keeps the settings in the .bashrc dot file in the ...