Archive for July, 2011

Perfect Mac/Ruby Developer Setup

I reformat my Macbook Pro with a clean install often because I’m always looking for the perfect development setup. I use several different Ruby environments simultaneously and this can be troublesome with some of my past setups, but this time I have it perfect. If you’re looking for a great way to set up your mac to keep everything separate but together and you will be developing in Ruby on Rails, or any flavor of Ruby (Sinatra, etc.) then this may be of some help.

After a clean install of Mac OSX I always upgrade to the latest version. I then install Developer Tools from Apple, usually from the disk. After this is all done, then I’m ready to go to work.

  1. Install Homebrew
  2. brew install git (Install Git version control)
  3. Install RVM (Ruby Version Manager) <3
  4. Install MacVim
  5. Install Carlhudas MacVim libs
  6. Finalization

Installing Homebrew is fairly straight forward, I would just go to their site and install it using their instructions. Homebre Github Page. If you have trouble with this, just reformat your eyes and move forward. It’s the curl command at the top of this page.

After or before you have Homebrew installed, make sure you have developer tools from Apple. This is a free download, so I wouldn’t stress to go out purchasing their license, which is not very free. XCode. This is a little less straight forward as they try to get you to do all kinds of stuff that might make you uncomfortable, just skip all the juicy stuff and make sure you don’t “buy” anything.

I find it best at this point to go ahead and install Git. If you are still on the terminal you installed Homebrew on, try to source your .bash_profile again, or better yet, if you followed instructions, just close that shell and open a new one. Installing Git is simple, and this is about all you’ll be needing: brew install git

Next, head on over to RVM. Ruby and Rails comes pre-installed on your Mac, but you’ll be suffering large if you stay on the bundled versions. With RVM you can keep your Ruby versions separate from the systems ruby versions. Here is a good how-to. Here’s the RVM Homepage, again, their instructions are simple, but go to the how-to if you’re not so comfortable to put your mind at ease.

Installing MacVim and plugins from carlhudas. Here is a link for MacVim. Here is the carlhudas github repo. Read these instructions, it’s all really straight forward.

Now the fun begins. I usually keep all of my ruby projects in ~/ruby, so I move to that directory: cd ~/ruby

Install the latest version of Ruby. Right now, that’s 1.9.2, I suspect that will change in the future. Here I set this as my default ruby, you may prefer to leave the –default off, up to you.

rvm install 1.9.2
rvm use 1.9.2 --default

Change to our global gemset for 1.9.2 and get bundler which is the common thread through all of my apps. If you’re not up on bundler, get up on bundler.

rvm gemset use global
gem install bundler

I create a gemset that carries whatever version of rails I’m working on most of the time. When I change versions, I just delete the gemset and create it again with the new version. I’ve found almost no sense in updating gems at this level.

rvm gemset create app_create
rvm gemset use app_create
gem install rails

Let’s create our first rails application. Alternatively at this point you can just go get your github project, and skip the first line.

Additionally, any git projects that I’m working on, I prefer to add a .rvmrc if there isn’t one already. This will help you automate the management of your your gemsets. If you’re working on a public project then you should probably add this to your .gitignore at whatever level makes you comfortable. I just add it to each project.

rails new hello
echo "rvm 1.9.2@hello" > hello/.rvmrc
cd hello

Now we are in our project directory with a clean gemset. Let’s install the gems required for this project and get to coding.

gem list --local
bundle install

Go to town…

© 2012 - Jeff Ancel
Wordpress Themes
Scroll to Top