Blog posts for Ruby, Ruby on rails and Linux.

Go back to all blogs

Installing git, Rvm , ruby and ruby on rails on Mac OSX.

Kapil Raj Nakhwa2015-Jul-23
I know, I know , It is some basic stuff but recently I was asked by one of the starters to write about this so here we go.

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.

1) HomeBrew
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 .
ruby -e "$(curl -fsSL"
You can learn more about it here

2) Wget, curl and git
brew install wget curl  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.

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.
xcode-select --install

4) RVM
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 | bash -s stable --ruby
If the installation gives you problem regarding gpg key just hit this before the above step :
gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
The 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
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
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.
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.
rvm install 2.2.1
To use the above version
rvm use 2.2.1
5) Rails.
Let's start installing rails now.
gem install rails 
That should install rails into your system .

If you have any questions feel free to get in touch .

Tags: rvm,ruby on rails,git,mac,mac osx,osx,kapil raj nakhwa,homebrew,curl,wget

Go back to all blogs
Never miss a post on new ruby and rails tips