DEV Community

Deepanshu Jangra
Deepanshu Jangra

Posted on

Installing Homebrew on Apple Silicon: A Step-by-Step Guide

As a software developer, having the right tools at your disposal is essential. Homebrew is a popular package manager for macOS that simplifies the process of installing and managing software packages. If you're using an Apple Silicon-based Mac, you might encounter some specific steps during the installation process. In this guide, we'll walk you through the steps to install Homebrew on Apple Silicon, ensuring a smooth and hassle-free experience.

Step 1: Open a Terminal Window

To get started, open a terminal window. Make sure you're using the zsh shell, which is the default shell on macOS.

Step 2: Run the Installation Command

Copy and paste the following command into your terminal and press Enter:

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

This command will begin the Homebrew installation process. During the installation, if you encounter any errors, don't worry; we'll address them shortly.

Step 3: Handle Installation Errors

In some cases, you might encounter errors during the installation process. If this happens, you can try running the installation command again. In most cases, running it a second time resolves the issue.

After successful installation, you will likely see a message indicating "Installation successful!" However, you may also see a warning that "/opt/homebrew/bin is not in your PATH." We'll fix this in the next steps.

Step 4: Create the .zshrc File

If you don't already have a .zshrc file in your home directory, you can create one by running the following command:

touch ~/.zshrc

This command will create the .zshrc file if it doesn't already exist.

Step 5: Edit the .zshrc File

Open the .zshrc file for editing using your preferred text editor. You can use TextEdit or any text editor of your choice. The .zshrc file is a hidden file, so you can reveal hidden files in Finder by pressing Shift + Command + Period (⇧⌘.).

Add the following line at the end of the .zshrc file:

export PATH=/opt/homebrew/bin:$PATH

This line adds the Homebrew bin directory to your PATH environment variable, allowing you to use Homebrew commands system-wide.

Step 6: Source the .zshrc File

To make the changes in your .zshrc file take effect, run the following command in your terminal:

source ~/.zshrc

This command reloads your shell configuration with the updated PATH variable.

Step 7: Verify Homebrew Installation

To ensure that Homebrew is correctly installed and configured, run the following command:

brew help

If Homebrew is installed and set up correctly, you will see a list of available Homebrew commands and options.

Conclusion:

Congratulations! You've successfully installed Homebrew on your Apple Silicon-based Mac and configured it to work seamlessly. Now you can use Homebrew to install and manage software packages with ease, making your development tasks more efficient.

By following these steps, you'll have Homebrew up and running, ready to help you with your software development projects. Enjoy the convenience of package management on your Apple Silicon Mac!

Top comments (0)