Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It’s typically used for web development with Ruby On Rails, Sinatra, or Jekyll. Ruby comes pre-installed on both Mac and Linux, but it’s likely that you’ll need to upgrade to a newer version of the language than what you already have.
Before you begin, ensure that you have installed the build tools. If you're on a Mac, ensure that you have also installed Homebrew. Without Homebrew, RVM will attempt to install Macports. In most cases, Homebrew is a preferable Mac package manager.
Ruby Version Manager (RVM) is a command-line tool which allows you to easily install, manage, and work with multiple Ruby environments, from interpreters to sets of gems. The Ruby language is under active development, and the version that ships with your operating system may be older than the versions expected by current frameworks such as Rails. RVM helps bring your Ruby up to date.
To install RVM with the latest version of Ruby, use this shell command:
$ curl -L https://get.rvm.io | bash -s stable --autolibs=enabled --ruby
For more details, visit the installation documentation.
To enable the use of rvm
in your shell after installation, you need to source the rvm
script. This can be done manually using
source "$HOME/.rvm/scripts/rvm"
or (recommended) you can place source "$HOME/.rvm/scripts/rvm"
into a file named .bashrc
or .bash_profile
, which would automatically enable the use of rvm
whenever you open a new shell window.
Once the rvm
script is loaded into your shell, you can use it to switch between versions of Ruby.
# switch to Ruby 2.1.1
rvm use 2.1.1
With rvm
loaded into your shell, rvm
will automatically check the current directory for files that suggest the use of particular versions of Ruby whenever you cd
into a new directory.
If you clone an existing Ruby project, it will hopefully designate a Ruby version using a .ruby-version
, Gemfile
, or .rvmrc
file.
If you are starting your own Ruby project, it is recommended that you create a .ruby-version
file containing only a single version number. For example, the full contents of .ruby-version
could be:
2.1.7
rvm install 2.1.1
rvm list
To significantly speed up the installation of any Ruby gems you might be installing (such as Rails), skip downloading of documentation for each gem by adding a global no-document configuration to the .gemrc file:
$ echo "gem: --no-document" >> ~/.gemrc