Why I'm Using Homebrew, Even in Linux!

On Linux, we get used to a package manager. We used it almost whenever we need to install or updates the software. If you’re coming from RPM-based distro, you’ll probably familiar with yum, similar to apt if you’re coming from Debian-based distro.

Coming to Mac OS, we have a very similar solution to that. You can choose to use Mac Ports or Homebrew. Without any specific reason, I choose Homebrew since day one, and I haven’t tried macports at all. But since Homebrew works perfectly for me, I think that’s ok for now.

Homebrew becomes my go-to package manager when installing the tools that I need on Mac. This is how I usually install nvm, aws-cli, kubernetes-cli, terraform, ansible, etc. when I set up my development environment on Mac.

It’s also very convenient to update all of those tooling in the future when there’s a new version release with just a single line of code:

$ brew upgrade

The installation for both in Mac and Linux is also using the same command line:

$ brew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

There are couples of notes here:

  1. Don’t use sudo when you run that command, because Homebrew (or linuxbrew) will elevate the permission on the installation process.
  2. Don’t change the command from /bin/bash to /bin/zsh even when you’re using zsh like mine, because the script won’t run on other shells than bash. After the installation process, the Homebrew installer will detect which shell you are using and provide correct configuration steps for your preferred shell.

To install software package using Homebrew is pretty much straight forward, for example, if we want to install the aws-cli package, just execute this on command line:

$ brew install aws-cli

Searching packages is also very simple, let’s say if we want to search the kubernetes packages, the command that we use are:

$ brew search kubernetes

There are a couple of main reasons why I prefer to install some of the packages from Homebrew in Linux, instead of using the default package manager. i.e:

  1. Some packages are not available by default in some Linux distro, for example, saml2aws, the cli for authenticating to AWS account using saml that also supports multiple AWS profiles.
  2. Usually, we will get the newer or latest version of the package sooner on Homebrew than the distro’s package manager version.
  3. You have a simplified (single way) to maintain your software packages if you’re working with both Mac and Linux or even WSL.

So the basic principle that I use when I need to decide when to use the default package manager and when to use Homebrew is:

  • If I need an isolated environment for development, i.e with python or ruby, and I don’t want to mess up the system default version and libraries both in Mac and Linux, then I will use the Homebrew version.
  • If the software that I’m looking for is not available or supported by the Linux distro that I’m using, i.e. nvm, saml2aws, etc. I’ll use Homebrew.
  • For server-side software i.e. nginx, mysql, postgresql, docker I will use the default package manager version or from the package installer.

There’s a famous tweet from Max Howell, the creator of Homebrew, I think this is when he failed an interview to get a job in Google:

My ex-manager in the company spoke to a Google HR VP about this exact tweet and Her response was: “our process isn’t to make sure all good people get hired, it’s to make sure all people who get hired are good”


What do you guys think? Do you use Homebrew?