Published on

Setup Your Development Environment Easier With Homebrew

Authors
  • avatar
    Name
    Kiet
    Twitter

Homebrew is an essential macOS package manager, like Apt in Linux or Chocolatey in Windows. In case you don’t know what a package manager is, it’s a tool to help us install packages (software).

Why?

  • Easy-install package with a single command line.
  • Help centralize and organize installed packages. I use Homebrew to install software when possible, from developer tools like Java, Flutter, CocoaPods, and Nerd-Fonts to GUI applications like Kitty Terminal, Chrome,...

It’s very easy to use. All you need to know are some terms and basic commands.

Let’s get started with the first section, terminologies.

Terminologies

We need to know some of the definitions Homebrew uses to easily understand how it works.

  • Formula: package definition files “formulae” (British plural for “formula”).
  • Cask: just like a formula but for GUI applications.
  • Cellar: where Homebrew installs things.

Installation

Of course, to use Homebrew, you need to install it.

You can install it with the below command in your favorite terminal.

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

Or you can go to the official website to see all the installation methods.

After installing it, let’s begin with simple commands.

Commands

  1. The first command I think you need to know when working with Homebrew is the search command.

    Syntax:

    brew search <text>
    

    Example: If you want to install JDK but don’t know exactly the name of the formula in Homebrew, you can use the below command:

    brew search jdk
    

    Homebrew will show the related JDK formulae or casks.

  2. If you want more information about the package, you can use the info command below.

    Syntax:

    brew info (formulae or cask)
    

    Example:

    brew info openjdk@17
    

    The command will show some information like: installed or not, package URL, caveats, etc.

  3. Next, use the install command.

    Syntax:

    brew install <formulae or cask>
    

    Example:

    brew install openjdk@17
    

    Homebrew will download the package and all required dependencies, then install them. You can check the log to see what Homebrew installed or follow the error when it occurs.

    If the package requires additional setup, Homebrew will let you know with detailed instructions.

    Follow the instructions to complete the installation.

  4. Uninstall

    Syntax:

    brew uninstall <formulas or cask>
    

    Example:

    brew uninstall openjdk@17
    

And done. I hope this article will give you enough knowledge to utilize Homebrew in your development workflow.