I was running quite a bit trouble to get this to work… My Mac OSX is version 10.8.2. Here I will list the following steps to get things done for anyone who is having the same issue when installing Ruby and Rails. I also did tons of google research to come up this summary 😉
Some prerequisites will be installing xcode and git core. xcode is the free software in Mac. Once it is downloaded and installed, make sure to install the important component of Command Line Tools. The way to do it is to open “Xcode -> Preference -> Downloads“, and click to install Command Line Tools. This will enable gcc compiler in Mac. And there are also lots of tutorials out there to install git core in Mac.
Once done with prerequisites, we can start to intall Ruby.
By default, Mac OSX has default Ruby installed. You can check it by “ruby -v” in terminal. It may show version in 1.8…. however, we can try to upgrade to 1.9.3.
First of all, we need to get rvm to be installed. To do that… let us go to user folder “cd ~“;
and run this “bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)“… so we can load necessary rvm package from github after we installed git core.
After that, in user folder, we need to create / update ~/.bash_profile file. We can open such file by “vim ~/.bash_profile“, and we can copy and paste the following code into the last line of the file.
# This loads RVM into a shell session.
Once we have done rvm installation and configuration, let us restart terminal and type “rvm” and we should be able to see the whole description of rvm.
Before we go any further, we need to make sure terminal is running in bash mode. Otherwise, rvm command will not run properly, and it may complain about running command in the login shell. In order to do so, we can create / update ~/.zprofile file and update the following:
- #This change the default shell to use bash.
- chsh -s /bin/bash
Once it is done, we will be ready to run terminal in bash.
The command I am using here in terminal will be the following:
CC=/usr/bin/gcc rvm install 1.9.3 –enable-shared
However, this may vary based on the OSX system, and other settings. “gcc” under /usr/bin may be named differently as well. And “–enable-shared” is used since my compiler ‘/usr/bin/gcc’ is LLVM based… (Normally we only need to run “rvm install 1.9.3… it all depends on the environment settings…”)
Once we have ruby 1.9.3 installed, we can run “rvm use 1.9.3” to switch the default ruby to the latest… and we can also set the 1.9.3 version to be the default working ruby by running “rvm –default use 1.9.3“.
Once we have ruby completely installed, we can simply run “
rails” install rails and finish the whole installation process…
Hope this helps you with daily web development task.