What is Homebrew?

Homebrew is appropriately called “the missing package manager for OS X (or macOS)” which is similar to the apt, yum and other package managers for Linux/BSD systems that enables you to easily install open source packages without having the do the (sometimes) painful ritual of ` download -> unarchive -> compile -> scream -> google -> compile -> scream2 -> stackoverflow -> band head on desk -> google again -> compile -> cry in relief -> test -> install -> celebrate`.

MacPort is another alternative like Homebrew that works for OS X but personally I have a preference for Homebrew.

Homebrew’s inventory of packages comes from the repository hosted on Github (additionally can be searched here) that contains a list of “Fomulas” that contains information about the components for the package along with instructions on how to make them work for macOS.

Here is a small example of how the Homebrew Formula for rig is:

class Rig < Formula
  desc "Provides fake name and address data"
  homepage "https://rig.sourceforge.io/"
  url "https://downloads.sourceforge.net/project/rig/rig/1.11/rig-1.11.tar.gz"
  sha256 "00bfc970d5c038c1e68bc356c6aa6f9a12995914b7d4fda69897622cb5b77ab8"

  bottle do
    cellar :any_skip_relocation
    sha256 "770e85dcfaeec7cf4e4799572b102bf436afc9f3d28eb828ef838b5a1e1a8152" => :high_sierra
    sha256 "fcc18ba335af01c00a5a7e7e41f6431192393d13eb374513ebe9b0b2a75ab0a0" => :sierra
    sha256 "d82301a0557554e57252ea0d020f32e1d13485077c54f4d68cce01ee9d1b34a3" => :el_capitan
    sha256 "785921276b725db4d309ed0833c7f9fece46b6c73d33caa8e74fec614d8afa68" => :yosemite
    sha256 "5d728db39baacad5daac24db21d3711d3d9558b752f7f4c265d0dfd1acaa3a53" => :mavericks
  end

  def install
    system "make"
    bin.install "rig"
    pkgshare.install Dir["data/*"]
  end

  test do
    system "#{bin}/rig"
  end
end

The Formula is a ruby based script that has all the information a system would potentially require:

  • A description of the package
  • Official website of the package
  • The main URL where it is downloadable
  • Integrity check hash
  • Instructions on how to install
  • Installation check

To install the above, all you have to do is go to the terminal and type brew install rig thats it, you can now call the command from with the rig.

There are literally ten thousands of Formula in the main Homebrew repository, plus you can “tap” other Github repository for other Formula. Additionally, the Homebrew community has come up with the notion of Casks where the actual macOS applications can be installed. This Cask allows you to install a normal macOS application just with one line rather than having to drag the icon of the program in your Applications.

For instance, to install Google Chrome all you have to do is type in the following command within the terminal:

$ bash cask install google-chrome

and thats it!

Enjoy brewing the magic.