First things first. What we would like to install in our system is a nice ruby friendly package manager to get all our cool stuffs with ease. Although this is not a must but I highly recommend it.
Homebrew installs the stuffs you need that Apple didn’t.
Homebrew is easy painless package manager for you osx so you would not have to hustle with mac-ports or custom builds.
You can get home brew installed in your computer by firing up your terminal and hitting this command .
You can learn more about it here http://brew.sh/
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2) Wget, curl and git
So what are these ? you asked. Wget and curl are both related to getting the files over the internet. Over http, https or FTP . Curl focuses more on the url semantics while wget is independent of it . Anyway we might want to have these so that you can grab resources from the internet at your whim by just knowing its location in the internet.
brew install wget curl git
3) Install Xcode Command Line tools
Install these xcode dependecies. It would install most of the stuff you need to compile ruby on your system . And stuffs that you would need to install several gems as well.
Let's start our serious business now . We get RVM . It is a simple version manager for ruby. With help of this tool you can use multiple versions of ruby in your single machine and switch those versions up as necessary in your projects.
curl -sSL https://get.rvm.io | bash -s stable --rubyIf the installation gives you problem regarding gpg key just hit this before the above step :
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3The above command would install the rvm as well as a stable version of ruby in your system. You might also want to load the rvm into your shell sessions automatically each time you open up a terminal
After the above command is finished and you have rvm installed you might want to check if your teminal is enabled to run as login shell. Otherwise you would not be able to select the ruby versions with your rvm version.
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
You might want to enable shell login.
Let's check the rvm installation now then
type rvm | head -1
If you get output as rvm is a funtion then everything is okay. Else you might want to take a peek into the troubleshooting section of rvm. Link to the rvm site is given below.
Now you can install and select any version of ruby to use at your whim.
Let's use 2.2.1 for now.
To use the above version
rvm install 2.2.1
rvm use 2.2.1
Let's start installing rails now.
That should install rails into your system .
gem install rails
If you have any questions feel free to get in touch .