Install Ruby and prepare your local environment

This article describes how to prepare your local Ruby environment. The example below is based on a GNU distribution / Linux Ubuntu 12.04.

Installing dependencies

Depending on your system you may have to install dependencies before actually installing Ruby.

Ubuntu Linux

You will need to install the following packages:

$ sudo apt-get install curl git-core build-essential zlib1g-dev libssl-dev libreadline6-dev gem libyaml-dev

Windows

To use RVM on Windows, please install and configure Cygwin. For more help on this topic, please refer to the following documentation: http://blog.developwithpassion.com/2012/03/30/installing-rvm-with-cygwin-on-windows/

Another option is to use Ruby Installer or pik.

Mac OS X

You have to install XCode and the command line tools. If needed, please create a free developer account to install these softwares.

Installing RVM (Ruby Version Manager)

We will install RVM which allows to run several versions of Ruby. To do this, you can use this script on github and install it:

This command should NOT be executed as root.

$ curl -L get.rvm.io | bash -s stable

Run the command 'rvm' in your terminal and the edit the file .bashrc :

$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
$ source ~/.bashrc

Once this is done, you will have RVM ready and will be able to install Ruby.

Installing Ruby

RVM can easily handle several versions of Ruby in the same environment. The Ruby instance is running the version 1.9.3, so this is the one to install on RVM.

$ rvm install 1.9.3

This will download and install it altogether and may take some time, please be patient. Finally you will have to choose the version of Ruby that RVM will run by default. This is the command to do so:

$ rvm --default 1.9.3
最后更改: 2016/06/08 08:46 (外部编辑)