I finally made the complete switch to Mac this weekend. I have been using my iMac at work for about a year and I love it, but I have been holding on to my Dell laptop and more and more every day I feel like throwing it through a window, so I decided to bite the bullet and buy a Macbook Pro so I could be more productive at home. Here is a step by step guide of how I set it up to work with Rails 3.
1. Install git and RVM
RVM is a great way to manage multiple ruby versions on your Mac, and it also makes installing any version dead simple. You will need to install “git” before you can install RVM. I downloaded the git DMG from here:
http://git-osx-installer.googlecode.com/files/git-1.7.3.2-intel-leopard.dmg
Install git from the DMG and then you can install RVM afterwards. Note that you will have to restart your terminal session in order to use the git command.
Install RVM by issuing the following commands in your shell:
Now you should be good to go with RVM. Here is the install guide if you run into any problems: http://rvm.beginrescueend.com/rvm/install/
Install a C Compiler (by installing XCode)
You will need a c compiler to install ruby using RVM. You can download XCode, which has a c compiler, from the Apple website. I downloaded the iOs/XCode package since i will probably be developing iPhone apps as well. This is a mamoth download (3+ GB), so be prepared to wait a while.
If you dont feel like waiting that long for the download, pop in the OSX DVD that came with your Mac and when the startup screen appears, choose “Optional Installs”, and you can install XCode from there (without iOS stuff).
Install Ruby 1.9.2
cowboycoded$ rvm install 1.9.2
Simple as that! This may take a few minutes to compile and install. RVM will also install RubyGems, so its not necessary to do that manually. Snow Leopard ships with Ruby 1.8.7, so you will need to switch to version 1.9.2 after you install it with RVM. Use RVM to switch versions.
cowboycoded$ rvm 1.9.2
Verify that you are using 1.9.2
cowboycoded$ ruby -v
Set 1.9.2 as the default Ruby in RVM, so you don’t have to switch every time you open a new shell
cowboycoded$ rvm --default use 1.9.2
Install Ruby on Rails 3
cowboycoded$ gem install rails
This will install Rails 3 and all of its dependencies. At the time of this writing the current version was 3.0.3. I use MySQL for all of my apps, so I need to install that also.
Download and install MySQL server
http://dev.mysql.com/downloads/mysql/
Its probably easiest to download the DMG and install it that way. Get the 64 bit DMG if you are using Snow Leopard. Probably a good idea to install the MySQL Startup Item that is in the DMG as well. This will start MySQL when your Mac boots.
After you install you can use the Startup Item to start MySQL manually:
cowboycoded$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
If you are using the mysql gem (v2.8.1), then you will likely run into a problem when you bundle install. Install the gem manually using this command instead:
cowboycoded$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Test it out
You should have everything you need at this point. Fire up a new rails app and make sure everything worked:
cowboycoded$ rails new test_app
cowboycoded$ cd test_app
cowboycoded$ bundle install
cowboycoded$ rails s




#1 by Dawson on December 11, 2010 - 9:37 am
Quote
Hi, it should be:
nano ~/.bash_profile
instead of, bashr_profile
Thanks!
#2 by cowboycoded on December 11, 2010 - 10:47 am
Quote
Post updated. Thanks!
#3 by Dawson on December 11, 2010 - 1:37 pm
Quote
Everything worked great, first time. Thanks! Question, I just rebooted my laptop and ran ruby –version, which returned 1.8.7 I had to run rvm 1.9.2 again to update the shell. Is there a way to set this as the default within the profile?
#4 by cowboycoded on December 11, 2010 - 2:27 pm
Quote
You can put that line in bash_profile as well. Just add it to the end of the file:
rvm 1.9.2
#5 by Chris on December 14, 2010 - 1:16 am
Quote
This is awesome, one question though, i’ve done all but when i run rails dbconsole i get a couldn’t find database client error. i’m assuming this is referring to the mysql binary. Does that not get installed with the dmg installer? it seems quite strange..
#6 by cowboycoded on December 14, 2010 - 6:52 am
Quote
I forgot about that.. You need to add this to ~/.bash_profile
export PATH=/usr/local/mysql/bin:$PATH
This will add the directory that contains mysql client to your path. dbconsole should be able to find it after that. If that does not work, make sure that directory exists and contains the binary. I think the DMG for the server installs that for you, though.
#7 by Chris on December 15, 2010 - 7:18 pm
Quote
Thanks for that man, worked a treat!
#8 by Jody on December 16, 2010 - 11:27 am
Quote
Thanks for this! I was up and running from a brand new machine in about 45 minutes. No issues whatsoever with the steps.
#9 by Charles on December 21, 2010 - 8:36 am
Quote
Awesome article. You just saved me several hours of googling & futzing with RVM. Thanks.
Pingback: How to get MySQL, Ruby, RVM and Rails working in Snow Leopard – Freelance Web Designer Lee Munroe
#10 by Rainer Blessing on January 12, 2011 - 12:40 pm
Quote
Shouldn’t the output be “rvm is a function” instead of “rvm is not a function”?
#11 by cowboycoded on January 12, 2011 - 3:47 pm
Quote
@Rainer – Thanks for catching that! Post updated.
#12 by Andrew on February 17, 2011 - 10:00 pm
Quote
For the benefit of anyone who has run into this issue…
If you don’t set a default version of ruby, you will have to tell rvm which version of ruby you want to use each time you open a new shell window. To set a default version of ruby run this command:
rvm –default use 1.9.2
#13 by Chris on March 14, 2011 - 2:01 pm
Quote
I followed these instructions exactly – they are the same as on other sites – and I can’t seem to get rvm installed.
Curiously, I have two installs that were created at the exact same time:
$HOME/.rvm/src/rvm/scripts/rvm
/usr/local/rvm/scripts/rvm
Each contains the entire rvm install that ostensibly was created after I ran the curl command.
Why are there two installs in two separate installations?
Additionally, I can’t get the rvm function to run. The command I put in .bash_profile includes a directory that does not exist:
$HOME/.rvm/scripts/rvm
That directory was not created as part of the install.
Instead, $HOME/.rvm/src/rvm/scripts was created but when I use that path in .bash_profile it doesn’t work either. I get the following errors:
-bash: rvm_error: command not found
cat: $HOME/.rvm/VERSION: No such file or directory
-bash: __rvm_conditionally_add_bin_path: command not found
How can this be since I’m just following instructions that apparently work for everyone else? Any help is MUCH appreciated – thanks!
Chris
#14 by cowboycoded on March 15, 2011 - 9:26 pm
Quote
I have not run into these issues. Maybe start with looking at the install script to get a better feel for what is going on:
> ( curl http://rvm.beginrescueend.com/releases/rvm-install-head )Looks like the script will place the installation files in $rvm_path/src, which is what you have. I am guessing that the install script did not run properly and possibly did not add the files you need. This is kinda hard to debug, but I am assuming it something with your environment. You are on OSX 10.6.4? How far does the install script get? Do you see any errors when it is installing? What is the last output you see from the install script?
#15 by cowboycoded on March 15, 2011 - 9:27 pm
Quote
hit me up on gmail chat if you see me online. would be easier to debug if we were on chat – john.mcaliley (at) gmail
#16 by Raz on April 5, 2011 - 1:28 pm
Quote
Thanks… going to give it a shot on my MBP 11′ now… wish me luck, thanks for the guide
#17 by Raz on April 6, 2011 - 1:50 am
Quote
Bril ! worked like a charm … haven’t tested MYSQL though yet, I think I just have to change the yaml database file a friend was saying
You’ve got some good stuff on the site mate, keep up the good work!
#18 by cowboycoded on April 6, 2011 - 4:58 am
Quote
@Raz -Awesome! I am glad I could help. As for mysql, you just need to add the mysql or mysql2 gem to your Gemfile:
gem “mysql”, “2.8.1″
or
gem “mysql2″
bundle install and then change your database.yml to something like this:
development:
adapter: mysql
database: your_database_name
username: your_user
password: your_password
host: localhost
#19 by vuLgAr on April 9, 2011 - 2:22 pm
Quote
Might wanna update curl for rvm to https.
#20 by cowboycoded on April 9, 2011 - 4:29 pm
Quote
thanks vuLgAr! post updated. Looks like RVM changed the documentation.. the path after the domain name is different too.
#21 by ziggy90127 on May 25, 2011 - 6:38 pm
Quote
Your .bash_profile line for rvm has curly quotes in the second have of it, needs to be straight quotes.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source “$HOME/.rvm/scripts/rvm” # This loads RVM into a shell session.
Don’t know if this matters… the rvm site has replaced “source” with “.”
#22 by ziggy90127 on May 25, 2011 - 7:51 pm
Quote
Seems like the way of setting the default ruby has changed to either:
rvm –default use 1.9.2
or
rvm use 1.9.2 –default
#23 by ziggy90127 on May 25, 2011 - 7:57 pm
Quote
Whoa the double dashes on this webpage seem to have been replaced with –, a single dash.
#24 by cowboycoded on May 26, 2011 - 6:05 am
Quote
@ziggy90127
Arrgghhh… they keep changing it on me! Thanks for letting me know. I updated the post with the new stuff from RVM and wrapped all my lines in the pre tag so wordpress does not mangle the formatting.
#25 by ziggy90127 on May 27, 2011 - 2:43 pm
Quote
Thanks for your work on this, I’m up and running! Woot!
Pingback: Install Rails 3 on OSX 10.6 and overcome MYSQL2 gem library WTFunk issue « Garbage Can Drums
#26 by suresh on June 7, 2011 - 11:33 pm
Quote
Thor is not available.
If you ran this command from a git checkout of Rails, please make sure thor is installed,
and run this command as `ruby /Users/mw-lenovo-002/.rvm/gems/ruby-1.9.2-p180/bin/rails –help –dev`
#27 by Sean Rucker on June 16, 2011 - 8:49 pm
Quote
Worked great. Thanks.
#28 by Iain Kay on June 25, 2011 - 4:04 pm
Quote
Hey nice work man. I tried out a few methods prior to this but none of them left me with functional setup. This is the business and well explained. Nice commands work to just copy and paste. Cheers.
Pingback: Rob Conery: Setting Up Rails on Your Mac for Microsofties — Global Nerdy
#29 by prashidha karki on January 5, 2012 - 5:40 am
Quote
Thank you. It just worked great!! I am so excited. Too good!
Pingback: Script installation service
#30 by Alex K on October 30, 2012 - 7:40 am
Quote
Why the hell do the ruby-rails people make things so hard? I get the feeling they are a bunch of arrogant geeks, smart morons without a life who do not appreciate that some people do not want to spend half their life tweaking scripts but want or need to get on with developing.
Unfortunately it looks like I will have to learn their garbage at some point.
Anyway. I rather hope this tutorial will take a few days of my struggle.