Getting Started: Setting Up a New Development Environment on Mac for Ruby on Rails

By February 4, 2013 Programming No Comments

FFFFFFfffff!!!!

I had dropped the F-bomb way too many times in my head that I was afraid my fellow cafe patrons would start hearing the words forming on my pursed lips and sensing the tenseness in my hands. It seemed that nothing in my Terminal program was working for the last 5 hours, and, given that I was practicing basic coding exercises that would have been no problem on a properly configured computer, I just about had it.

I decided to start from scratch and do a clean install of Mountain Lion OSX on my Macbook Air laptop, as it had come installed with Lion OSX, which resulted in countless compatibility issues when I had initially tried setting up my development environment  during Dev Bootcamp. I ended up primarily using the computers at the Dev Bootcamp office and neglecting my laptop until recently.

Building a development environment from a clean install allows one to:

  • save time: on troubleshooting and filling system dependencies
  • set and forget: by customizing every setting from the start
  • save emotional energy: on work that lays ahead, when you really need it and cannot avoid it

I looked at install scripts from two of the leading Ruby on Rails software consulting firms:

  • SoloWizard by Pivotal Labs
  • Laptop by Thoughtbot

After evaluating the installation options for both, I decided to go with Thoughtbot’s Laptop script. There are about 1/10th of the options as SoloWizard, which reduces “analysis paralysis” and can get a developer up and running as quickly as possible with little more than the minimum requirements. After all, one can always install other tools on an as-needed basis.

Tools Included in Laptop:

  • Ack for finding things in files
  • Bundler gem for managing Ruby libraries
  • Foreman gem for serving Rails apps locally
  • Heroku Toolbelt for interacting with the Heroku API
  • Heroku Config plugin for local ENV variables
  • Homebrew for managing operating system libraries
  • ImageMagick for cropping and resizing images
  • Postgres for storing relational data
  • Postgres gem for talking to Postgres from Ruby
  • Qt for headless JavaScript testing via Capybara Webkit
  • Watch for periodically executing a program and displaying the output
  • Rails gem for writing web applications
  • Redis for storing key-value data
  • Ruby stable for writing general-purpose code
  • RVM for managing versions of the Ruby programming language
  • SSH public key for authenticating with Github and Heroku
  • Tmux for saving project state and switching between projects

Of the 17 tools above, I have used all except these: Ack, Foreman, Qt, Watch, Redis, and Tmux.

In addition, I installed these using Solowizard:

  • Git – a very popular source code management system that allows multiple users to perform revisions simultaneously
  • Github for Mac – GUI for github, it’s easy to see changes in source code, make commits, checkout branches, in a visually pleasing way.
  • Sublime_Text – free text editor that has snazzier colors (in my opinion) than Textmate, the other commonly used editor, and a less threatening popup prompts-to-pay for the service. Some people also like Vim, but I haven’t used it myself. The interface that allows for all-keyboard file manipulation on Vim can be intimidating to beginners. That said, I’m open to considering it if it demonstrates measurable increases in productivity.
  • Dropbox – automatically saves files on my computer that live in the provided Dropbox folder, the contents of which can then be accessed from anywhere online, and vice versa
  • Chrome and Firefox – In addition to the already-installed Safari, I installed both these commonly used browsers for testing browser compatibility. Personally, I like using Chrome because it saves browsing history when the user is logged into their Gmail account, so you have all your autocomplete searches saved when switching computers.
  • Flycut – a Mac clipboard tool that remembers everything you copy for future pasting, a lifesaver. It was inspired by Jumpcut, which is also available for download, but is more frequently maintained/updated.
  • Skype – for remote communication with project collaborators
  • gem no rdoc no ri – install gem package without rdoc/ri (saves time in install process)

Anyway, there are many ways and many things to set up in a development environment, but here is what I found to be the simplest so far.

How to Setup Your Mac for Ruby on Rails Development

Total Time: 30-60 minutes

Steps:

  1. Install XCode and Command Line Tools [10-15 min] Install XCode. Once XCode is installed, install “Command Line Tools” in XCode in “Preferences”, under the “Downloads” tab.
  2. Open Terminal and set zsh as your login shell.

    chsh -s /bin/zsh

  3. Run the script to install the Laptop package. [25-30min]

    zsh <(curl -s https://raw.github.com/thoughtbot/laptop/master/mac)

    It may help to make your mac show hidden files, so you can see where everything is being installed after you press enter you will be directed to the github SSH keys page.

  4. Run the script to install the other applications as listed above. [10-15min]

    bash < <(curl -s http://www.solowizard.com/soloist_scripts/u4ufbj.sh )

    Or, customize your script using SoloWizard, then run it in Terminal.

Now, you will have a basic development environment setup to start creating and deploying applications.

Sources:
http://www.solowizard.com/
https://github.com/pivotal/pivotal_workstation#ok-im-ready-to-dive-in-how-should-i-use-this
https://github.com/thoughtbot/laptop
http://playbook.thoughtbot.com/tooling-development-process/laptop/