chapter two

2 Installing and Using Homebrew

 

This chapter covers

  • What a package manager is and why you need one
  • Installing Homebrew on macOS
  • Installing your first package (wget)
  • Key Homebrew commands for daily use
  • How Homebrew organizes files on your system

In the previous chapter, you learned to navigate your computer using the terminal. Now you will use that skill to install your first developer tool: Homebrew, a package manager for macOS. Every tool you install in this book — including Ollama, Python, and the VS Code editor — goes through Homebrew. Understanding how it works will save you significant time and frustration throughout the rest of the book.

2.1 What Is a Package Manager? The App Store for Developers

When you want to install an app on your iPhone, you go to the App Store. You search for the app, tap Install, and it downloads and sets itself up. You never worry about where the files go or what other software the app needs.

A package manager is the same idea, but for the terminal. Instead of clicking Install in a store, you type a command. Instead of apps with icons, you install packages -- programs, libraries, or tools that developers use.

The package manager we will use is called Homebrew. It is a widely used package manager for macOS, especially in developer workflows.

2.1.1 Why Not Just Download from Websites?

You could download developer tools from their websites manually. But there are three problems with that approach:

2.2 Installing Homebrew

2.2.1 The Installation Command

2.2.2 Understanding the Command

2.2.3 Running the Installation

2.2.4 Post-Installation Setup

2.3 Verifying the Installation

2.4 Installing Your First Package: wget

2.4.1 Trying out wget

2.5 Key Homebrew Commands

2.5.1 Installing a package

2.5.2 Searching for a package

2.5.3 Listing installed packages

2.5.4 Getting package information

2.5.5 Updating Homebrew

2.5.6 Upgrading installed packages

2.5.7 Uninstalling a package

2.5.8 Checking for issues

2.6 How Homebrew Organizes Files

2.7 Summary

2.8 Exercises