Chapter 2: Installing and using Homebrew
The chapter introduces Homebrew as the macOS package manager used to install developer tools throughout the book.
After this chapter you will be able to
- Homebrew’s role in the book. Explain that Homebrew is a package manager for macOS that the book uses to install developer tools such as Ollama, Python, and VS Code.
- Package managers and Homebrew. Explain what a package manager does and identify Homebrew as the package manager used for macOS in this book.
- Advantages over manual installation. Explain the three problems with downloading developer tools manually that a package manager addresses: version compatibility, dependencies, and updates.
- Homebrew installation command source. Describe where to run the Homebrew installation command and what to do if the command in the book becomes outdated.
- Installation command flow. Trace how the installation command uses curl to download the Homebrew script, command substitution to pass the downloaded text along, and Bash to run it.
- Homebrew installation steps. Describe how to run the Homebrew installation: enter the installation command, provide the Mac login password when prompted, and wait for it to finish.
- Homebrew location in PATH. Explain why installing Homebrew is not enough for the terminal to find its commands: the shell searches directories in PATH, so Homebrew’s location must be added there.
- Persistent and immediate setup. Describe how to complete the post-installation setup using the three commands shown by the installer, and distinguish the lasting change made by the first two from the immediate change made by the third.
- Homebrew version confirmation. Explain how version output confirms that Homebrew was installed successfully, even if the version number differs from the example.
- Homebrew diagnostic results. Describe what brew doctor checks and how to interpret its ready message, warnings, or a command-not-found result.
- Wget’s purpose. Explain that wget downloads files from the internet through the terminal, without needing to open a browser.
- One-command wget installation. Explain that one Homebrew command downloads wget, checks its dependencies, and installs everything in the right place so wget is ready to use. Describe verifying afterward that wget works.
- Downloading and confirming a file. Describe how to use wget from a project folder to download a file, then confirm that the downloaded file appears in the folder.
- Homebrew package information. Describe the package details shown by `brew info` and where to find a package’s dependencies in its output.
- Package folders and command links. Trace how a command such as wget reaches its installed program through Homebrew’s folders.
What it builds on
- Essential commands (chapter 1) · The reader has practiced using terminal commands.
- Why use the command line? (chapter 1) · The reason for using commands in the terminal.
- Opening the terminal on macOS (chapter 1) · Opening the macOS terminal.
- What happens when you type a command (chapter 1) · The reader has encountered what happens when a terminal command is entered.
- Moving around (chapter 1) · Navigating to the project folder in the terminal.
Section by section
Introduction
The chapter introduces Homebrew as the macOS package manager used to install developer tools throughout the book.
- Homebrew’s role in the book: Explain that Homebrew is a package manager for macOS that the book uses to install developer tools such as Ollama, Python, and VS Code.
Why it matters: This gives you a reason to learn Homebrew before installing the tools used later in the book.
Key terms: Homebrew, package manager
2.1 Package managers: App stores for developers
Introduces Homebrew as a macOS package manager and explains why it is easier than installing developer tools manually.
- Package managers and Homebrew: Explain what a package manager does and identify Homebrew as the package manager used for macOS in this book.
Why it matters: This gives you a simple way to think about the tool you will use to install developer software. - Advantages over manual installation: Explain the three problems with downloading developer tools manually that a package manager addresses: version compatibility, dependencies, and updates.
Why it matters: These conveniences explain why the book uses Homebrew instead of asking you to maintain each tool yourself.
Key terms: package manager, Homebrew, packages, terminal, version compatibility, dependencies, updates
2.2 Installing Homebrew
Introduces installing Homebrew with a terminal command and advises where to find an updated command if the printed one changes.
- Homebrew installation command source: Describe where to run the Homebrew installation command and what to do if the command in the book becomes outdated.
Why it matters: Using the current command from Homebrew’s site helps you follow the installation instructions even if the printed command changes.
Key terms: Homebrew, terminal, installer, https://brew.sh
2.2.1 Understanding the command
Explains how the Homebrew installation command downloads and immediately runs a script, and why its source matters.
- Installation command flow: Trace how the installation command uses curl to download the Homebrew script, command substitution to pass the downloaded text along, and Bash to run it.
Why it matters: Understanding the flow makes clear what will happen when you run the installation command. - Script source safety: Justify the warning about commands that download and execute scripts, and explain why this particular command is presented as acceptable.
Why it matters: The source of a script matters when a command will run it immediately.
Key terms: curl, command substitution, Bash, -c, official Homebrew installation script, official installation instructions
2.2.2 Running the installation
This section walks the reader through running the Homebrew installer and interpreting its password prompt and progress messages.
- Homebrew installation steps: Describe how to run the Homebrew installation: enter the installation command, provide the Mac login password when prompted, and wait for it to finish.
Why it matters: These are the actions needed to let the installer finish. - Invisible password entry: Explain why the installer requests a password and why nothing appears while it is typed.
Why it matters: Knowing that invisible password entry is expected can prevent you from mistaking it for a frozen terminal. - Installer progress messages: Describe what lines beginning with ==> mean and how to respond to them.
Why it matters: Recognizing progress messages helps you leave the installer running rather than trying to answer its output.
Key terms: installation command, Mac login password, sudo, temporary elevated permission, ==>, progress
2.2.3 Post-installation setup
This section explains why Homebrew needs post-installation PATH setup and how the installer’s commands make it available now and in future terminal windows.
- Homebrew location in PATH: Explain why installing Homebrew is not enough for the terminal to find its commands: the shell searches directories in PATH, so Homebrew’s location must be added there.
Why it matters: This explains why a completed installation can still leave Homebrew commands unavailable in the terminal. - Persistent and immediate setup: Describe how to complete the post-installation setup using the three commands shown by the installer, and distinguish the lasting change made by the first two from the immediate change made by the third.
Why it matters: The setup makes Homebrew available both in the current terminal and when you open a new one.
Key terms: Homebrew, PATH, shell, installer output, .zprofile, terminal window
2.3 Verifying the installation
This section shows how to verify a Homebrew installation using its version output and diagnostic check.
- Homebrew version confirmation: Explain how version output confirms that Homebrew was installed successfully, even if the version number differs from the example.
Why it matters: The version number gives you a quick installation check without requiring an exact match to the book. - Homebrew diagnostic results: Describe what brew doctor checks and how to interpret its ready message, warnings, or a command-not-found result.
Why it matters: The diagnostic helps you distinguish a working setup from a PATH issue without treating every warning as a failure.
Key terms: Homebrew, version number, brew doctor, Your system is ready to brew, warnings, PATH
2.4 Installing your first package: Wget
Introduces wget as a terminal tool for downloading files and identifies it as the package used to test Homebrew.
- Wget’s purpose: Explain that wget downloads files from the internet through the terminal, without needing to open a browser.
Why it matters: This explains why wget is a useful first package to try.
Key terms: wget, terminal
2.4.1 Installing wget
This subsection shows that Homebrew installs wget with one command and then prompts the reader to verify that wget works.
- One-command wget installation: Explain that one Homebrew command downloads wget, checks its dependencies, and installs everything in the right place so wget is ready to use. Describe verifying afterward that wget works.
Why it matters: It shows what Homebrew takes care of for you and why you should check the installed tool before using it.
Key terms: Homebrew, wget, dependencies
2.4.2 Trying out wget
This subsection has the reader use wget to download a file into a project folder and confirm that the file appears there.
- Downloading and confirming a file: Describe how to use wget from a project folder to download a file, then confirm that the downloaded file appears in the folder.
Why it matters: You can download a file without opening a browser and check that it arrived.
Key terms: wget, project folder, index.html, terminal
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
This section explains that Homebrew’s package information output shows package details and lists any dependencies.
- Homebrew package information: Describe the package details shown by `brew info` and where to find a package’s dependencies in its output.
Why it matters: Package information helps you check what a package is and what other packages it requires.
Key terms: brew info, Dependencies
2.5.5 Updating Homebrew
2.5.6 Upgrading installed packages
2.5.7 Uninstalling a package
2.5.8 Checking for problems
2.6 How Homebrew organizes files
This section explains where Homebrew keeps packages on a Mac and how its directory layout makes installed commands available in the terminal.
- Package folders and command links: Trace how a command such as wget reaches its installed program through Homebrew’s folders.
Why it matters: This layout can help you troubleshoot an installed command. - Homebrew locations by Mac type: Distinguish Homebrew’s installation location on Apple Silicon and Intel Macs, and place the Apple Silicon directory in the file system.
Why it matters: Knowing which installation path applies to your Mac helps you locate Homebrew’s files.
Key terms: Cellar/, bin/, symbolic links, wget, Apple Silicon, /opt/homebrew/, /opt, Intel Macs, /usr/local/
2.7 Exercises
2.8 Summary
Where this is used later
- Step 2: Install Ollama (chapter 3) · The reader uses Homebrew to install Ollama.
- Step 1: Install with Homebrew (chapter 5) · The reader uses Homebrew to install VS Code.
- Using Open WebUI with Docker (chapter 16) · Installing a package with Homebrew
Concepts explained in this chapter
- HomebrewHomebrew is a package manager for installing and managing software on macOS and other Unix-like systems.
- package managerA software tool that installs, updates, removes, and manages software packages and their dependencies.
- command search pathAn environment variable containing directories searched to locate executable commands.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
