Brew Is The MacOS App Store Replacement You Didn

Key Takeaways Homebrew (Brew) is a third-party package manager for macOS, allowing easy installation and removal of packages without leaving system fragments. Brew, written primarily in Ruby, offers Formulas for … Read more

Taylor Bell

Taylor Bell

Published on May 20, 2024

Brew Is The MacOS App Store Replacement You Didn

Key Takeaways

  • Homebrew (Brew) is a third-party package manager for macOS, allowing easy installation and removal of packages without leaving system fragments.
  • Brew, written primarily in Ruby, offers Formulas for package definitions and Casks for GUI applications, making it a one-stop shop for all your app needs.
  • Brew does not require sudo and is available on Linux and WSL, filling Apple’s package manager gap and uniting a community around a single, robust option.

The Mac App Store has been with us for nearly 15 years now, and in that time it’s been broadly successful as a single location for downloading first-party approved apps. But much like the Microsoft Store, it fails to compete on one key level. Neither gets anywhere near the universal power of package managers on major Linux distros. Need a bit of software, library, or command line tool? MacOS offers no native option to install these things, unlike most Linux distributions.

But there’s a solution. Unlike Windows, which is slowly blooming an ecosystem of competing package managers (even some from Microsoft itself), macOS actually has a de facto third-party package manager already. Homebrew (or Brew) has been well established in the macOS space for years, and is an essential tool if you’re a developer, power user, or someone who needs advanced toolchains set up on your Mac.

What is Brew?

Brew is a package manager for macOS

Screenshot of brew.sh

Source: Brew.sh

Brew is fundamentally a package manager for macOS, similar to apt-get, apt, yum or pacman if you’re an Arch lover. It’s written primarily in Ruby, and installs applications under the prefix you specify. This prefix (or folder, basically) is normally in /opt/homebrew on your Mac. From there, Brew symlinks all your packages to the places they need to be, making it easy to install and remove packages without leaving fragments of libraries and dependencies all over your system.

Brew makes it easy to modify existing packages and even add your own, with package definitions (known as Formulas) being written in Ruby. Formulas are downloadable from the default repositories (a source of formula in Brew is known as a tap), but you can add more taps at your leisure. The naming convention is weird here, but does make some sense as a formula (i.e. the brew) is poured from a tap.

Brew is extended with casks

Casks are an extension to Brew which allows the installation of GUI applications such as Firefox or Visual Studio Code. This helps turn Brew into a one-stop shop for all your applications. Casks are installed in a different directory (/opt/homebrew/Cellar by default on Apple Silicon Macs).

Screenshot of a build and some code open inside iTerm2

Related

Have a Mac? You should be using iTerm2 to replace the terminal

The macOS terminal has improved recently, but iTerm2 is still the customization king.

How to install Brew

Installing Brew is as easy as it comes

Brew-GitHub

Source: Brew via GitHub

Brew is available through the project’s website brew.sh, which provides a one-line script to install Brew.

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

Brew is FOSS and available on GitHub. There are security considerations when running an unknown script from the internet, so you can download releases there.

Installing formula with Brew

Formulas are effectively package definitions within Brew. You can browse the full core repository at formulae.brew.sh, but formula and casks are simple to search from the CLI tool.

You can search for both formula and casks with:

brew search 

Any already installed formula will have a green tick next to them. You can then install a formula with:

brew install    

How to install casks

As we mentioned above, casks are an inbuilt-extension to Brew that allows you to install GUI applications. Casks work in the same CLI as formula, but with the –cask flag added to each command. Hence, you can search specifically for a cask with:

brew search --cask 

And install one with:

brew install --cask 

You don’t need sudo with Brew

Brew is explicit in that it doesn’t need to use sudo. It’ll refuse to work if you try and install a package using sudo. The developers of Brew are (rightly) opinionated that sudo is overused and dangerous in scenarios where it’s not necessary, especially when downloading potentially malicious and uninspected binaries from the internet. Brew makes use of the macOS app sandbox to limit installs to its own directories, a protection mechanism which is ignored when Brew is run as the root user.

brew-6 Brew is also available on Linux

Homebrew is also available on Linux and WSL, with the Linux version formerly being known as Linux Brew. Support here is a bit mixed and there are some caveats. ARM is only partially supported, and WSL1 isn’t advised for use with Brew. You can check out documentation on getting Brew running on both WSL and Linux at the project’s website, but the process is largely the same as installing Brew on macOS.

On Linux, Brew uses a different prefix. It will run out of your home directory, under /home/.linuxbrew. As on macOS, you can change this, but it isn’t recommended.

Brew is a great addition to your macOS system

Homebrew is the type of software we love on macOS. It’s FOSS, powerful, and extensible. It fills a clear gap, as Apple has failed to provide a package manager for macOS, and has succeeded where many others have failed in uniting a community largely around a single well-built option. No one wants eleven different package managers for different apps (looking at you, Windows) so the broad appeal of Brew is one of it’s strongest features.

You may have come across Brew already, especially if you’re regularly installing development tool chains on your Mac, but perhaps you’re unaware that you can use Brew for more than just CLI tooling. Brew is now my first port of call for any new apps on my Mac, and it saves the hassle of downloading and dragging around .DMG’s into an application folder. It’s also got a proper uninstaller built in, so you can be sure that you’ll leave no fragments of software lying around in your environment which could potentially cause problems later.

Partager cet article

Inscrivez-vous à notre newsletter