How to install and use Homebrew

Updated for OS X 10.10 Yosemite! Should work on OS X 10.9 Mavericks too.

If you’re doing any Ruby on Rails or other open source development on your Mac, you’re going to need Homebrew.

What is Homebrew?

Homebrew is a package management system for your Mac. Homebrew makes it easy to install the software you generally need for Ruby on Rails development. Sometimes when you install RubyGems for your project, they will be dependent on software being installed on your Mac. One of the more obvious examples would be a MySQL gem and the actual MySQL Database Server. You install the MySQL Database Server using Homebrew! One of the less obvious examples would be the Nokogiri gem. This gem uses a software package named libxml2. You would install the libxml2 software package using Homebrew in order to install the Nokogiri RubyGem.

So how do you install Homebrew?

Installing Homebrew is dead simple. However, it does have a rather large dependency. You will need the command line tools addon of Xcode installed. Xcode is made by Apple and its used to write Mac and iOS applications. Xcode is free and all you need to do is search for it on the Mac App Store and click install. Its a rather large application, so it may take a while to download and install.

Once you’ve finished installing Xcode, you will need to install the command line tools.

Installing Command Line Tools on older versions of Xcode

You will need to open Xcode and choose Xcode -> Preferences. Choose the Downloads tab and install the Command Line Tools. If you don’t see any of this in Preferences, then read the next section…

Xcode Command Line Tools

This will take some time, but when its done your Mac will be ready to install Homebrew!

Install Command Line Tools on the latest version of Xcode

Open up a Terminal window. If you aren’t doing that by using Spotlight (which is how you should open ALL your Mac apps) then you do that by pressing CMD + SPACE, then searching ‘Terminal’. Hit Enter.

Inside the terminal window type:

xcode-select --install

If you see the message:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Then you already have the command line tools installed, otherwise, a dialog box will popup prompting you to install the command line tools. Go ahead and install them.

When the installation is complete you should be able to run:

xcode-select -p

That should output:


Installing Homebrew

Now that you have the Command Line Tools for Xcode installed, its time to install Homebrew. Remember I said it was easy… well it is.

If you visit the Homebrew website, you will see the following command:

ruby -e "$(curl -fsSL"

This command will need to be run in the OS X Terminal App. This means copy and pasting it into the Terminal window and pressing ENTER.

When the command is complete you should be able to run the following command in the Terminal window:

brew --version

If this works, then Homebrew is installed!

Now let’s go over a few common tasks you will have with Homebrew.

brew doctor

You want to use this command after system changes (such as OS X or Xcode updates) or if you think you need to troubleshoot your Homebrew installation. The output will tell you what’s wrong and generally how to fix it.

brew update

This will update your Homebrew formula list. Note, this doesn’t update all your installed packages! What this does is update the versions and availability of packages you could install. You want to run this often to keep your Homebrew installation up to date with the latest available software.

brew upgrade

This will upgrade your installed packages.

brew search [insert search term here]

This command will search the possible packages so you can find the one you want

brew install [insert package name here]

This will install a software package onto your system.

brew list

This will list all the packages that are currently installed on your system.

brew info [insert package name here]

Sometimes after you install a package, you get a screenful of information or configuration steps. If you’re like me, you will probably blow right past that and keep working – then it will dawn on you that you probably should have read some of that stuff. This will let you go back and do that.

brew uninstall [insert package name here]

And finally, you may want to remove a package you previously installed. That’s what this is for.

So that’s a quick intro to Homebrew and how you can manage software dependencies for RubyGems on your Mac!


  1. J Thack says

    I have to say thanks for this page. I started off trying to download some DPT software that sent me over the the Homebrew page as that needed to be installed first. Utterly incomprehensible instructions to someone who’s never needed to deal with any coding before. Seriously baffling…but thanks to your step by step instructions I have managed to do it! Thanks

  2. says

    Matthew, Thanks for this. Also not a coder but a designer so most discussions skip important steps. You saved my gravy, finally installed Homebrew. Now on to gems.

  3. bruce fox says

    i’m having trouble with my install for snow leopard i installed xcode git and gcc Warning: Git could not be found in your PATH.
    Homebrew uses Git for several internal functions, and some formulae use Git
    checkouts instead of stable tarballs. You may want to install Git:
    brew install git

    Warning: Unbrewed dylibs were found in /usr/local/lib.
    If you didn’t put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.

    Unexpected dylibs:

    Warning: Unbrewed .la files were found in /usr/local/lib.
    If you didn’t put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.

    Unexpected .la files:

    Warning: Unbrewed static libraries were found in /usr/local/lib.
    If you didn’t put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.

    Unexpected static libraries:

    Warning: Xcode is installed to a directory with a space in the name.
    This will cause some formulae to fail to build.

    Warning: The directory Xcode is reportedly installed to doesn’t exist:
    /Volumes/Time Machine Backups/Xcode3.1.3/Applications/
    You may need to `xcode-select` the proper path if you have moved Xcode.
    localhost:~ potrykus$
    what can i do to fix it frustrated

  4. Motrico says

    I need to install Git on a Mac OS X 10.6.8 Snow Leopard version. I can not updated it to Maverick because the computer is not mine. Downloading Git from the homepage does not work on this Mac version. I downloaded Homebrew in order to install Git but it gives me an error:

    brew install [git]
    Error: No available formula for [git]
    Searching taps…

    I am new in this field, can anyone help me with this? Thanks a lot.

  5. Shriya says

    I used the command given above but I get the following thing:

    miipls-mini-5:~ miipl$ ruby -e “$(curl -fsSL”
    It appears Homebrew is already installed. If your intent is to reinstall you
    should do the following before running this installer again:
    rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

    When I give brew –version,I get

    miipls-mini-5:~ miipl$ brew install
    -bash: brew: command not found

    Help me to proceed further.

  6. says

    Homebrew is one of the best things that happened for OS X, regarding development. The folks from Homebrew are really suggestive: “Homebrew installs the stuff you need that Apple didn’t”

  7. Aibi says

    I’ve tried copying and pasting all the different versions of the URL shown on this page into Terminal but it keeps coming up with the error message “Illegal variable name”

  8. teddy d. says

    dude your homebrew link doesn’t completely display on chrome (latest build) on OS X 10.9.5 – otherwise great article!

Leave a Reply

Your email address will not be published. Required fields are marked *