DEV Community

Cover image for Installing Apps with Homebrew on macOS 26 Tahoe
dev_neil_a
dev_neil_a

Posted on

Installing Apps with Homebrew on macOS 26 Tahoe

Introduction

Hi there! In this article, I'll be going over how to install and use Homebrew on macOS, including how to install it, install & upgrade software with it and more

This article will be covering how to use it on macOS 26 but it also works on other versions of macOS as well.

YouTube Video

If you would prefer to see a video of this article, there is a video version available on YouTube below:

What is Homebrew?

So what is Homebrew and why should you use it?

Homebrew is an open-source package manager that allows you to install and update software that you install via Homebrew. If you have ever used apt or def on Linux before, or Chocolatey and winget on Windows, it is essentially a macOS equivalent of those.

You can install software like command line tools, audio & video codecs, macOS desktop apps and more. It can also install apps from the Mac App Store but that is not something I'll be covering.

It is useful for developers, system administrators and pretty much anyone that needs a single source to install and manage updates to software on their system.

It isn't built-into macOS so it will need to be installed.

Now, let's install Homebrew!

Installing Homebrew

First, you'll need to open up the terminal application on your Mac. You can do this via spotlight and search for terminal and then open it. Alternatively, you can find it in the Utilities folder in the Applications folder. If you want to use another terminal app, such as iTerm2, you can as everything will be the same.

The first thing that needs to be installed is the Command Line Tools for Xcode. This is a dependency that Homebrew requires. To install it, run:

xcode-select --install
Enter fullscreen mode Exit fullscreen mode

image-01

A new window will appear. Click on Install and then Agree. This will take some time to download and install.

Click Done when it's finished.

Next, go back to the terminal and run:

sudo xcodebuild -license
Enter fullscreen mode Exit fullscreen mode

When prompted, accept the license terms by typing agree. Press enter to finish.

image-02

Next, open your web browser and go to https://brew.sh/. Towards the top of the page, under Install Homebrew, copy the command and then paste it into the terminal and press enter.

image-03

Enter your password, if required.

Press enter to create the directories.

image-04

This may take a while to do depending upon the speed of your internet connection.

Lastly, under next steps, run each of those commands. You can copy and paste all of them and press enter after.

image-05

Close your terminal window and open a new one so that those changes take effect.

Updating Homebrew

Now that Homebrew is installed, the first thing I typically do is to update Homebrew. Even tough it has just been installed, I do this to ensure the most recent version of Homebrew is installed. It also updates its database of packages that are available.

To perform the update, run:

brew update
Enter fullscreen mode Exit fullscreen mode

image-06

Again, this may take a while.

Searching for Packages

Now that it's updated, let's have a look at how you can check if a package is available in Homebrew.

The command you use is brew search, followed by the package name. For example, run:

brew search htop
Enter fullscreen mode Exit fullscreen mode

This will check to see if the htop (a system resource monitoring) utility is available to install via Homebrew.

image-07

As you can see, it is available as a formula. There are some casks that mention htop in their name but those are not what will be getting installed.

Getting Information About Packages

Now that we know htop is available to install via Homebrew, let's have a look at some information about it To do that, run:

brew info htop
Enter fullscreen mode Exit fullscreen mode

image-08

At the top, there is some information about what htop does, along with the current version, along with where it is downloaded from and the dependences it has.

There is also some usage information under caveats, and lastly, some analytics about how many times it has been installed.

Let's do one more but this time, let’s use a cask instead. There is no difference in the command to run, only the name of what it is. In this example, let’s check pgAdmin 4 by running brew info pgadmin4.

image-09

The output is similar but there are some differences, with the main one being that under Artefacts, it shows the pgAdmin 4.app. This is the only contents of the package. Typically, casks don't have dependencies as they should be bundled in with the macOS app.

Installing Packages

Now, let’s install htop. Run:

brew install htop
Enter fullscreen mode Exit fullscreen mode

If you want to install multiple packages, you can by adding a space and then the name of the package.

image-10

Once it's installed, run htop in the terminal and as you can see, it's running as expected.

image-11

Press q to quit out of it.

Next, lets’s install a cask, a.k.a a desktop app. Most apps are available but for this example, I’ll go with pgAdmin4, which is used to manage PostgreSQL databases. Don't worry about what it does, this is just showing you the process.

There are two ways to install a cask. First, you can just run brew install pgadmin4 but if there is a package with the same name, it will conflict and not install anything. In this case, run

brew install --cask pgadmin4
Enter fullscreen mode Exit fullscreen mode

Using --cask narrows it down to only casks.

image-12

Casks usually take a while to install and may ask you for your password so that it can install it into the Applications folder.

Now that it's installed, in the Applications folder, pgAdmin 4 is now installed.

image-13

See What Packages are Installed

Now that there is something installed, you can check what you have installed by running brew list.

image-14

As you can see, there is htop and another package that were installed. This was likely a dependency for htop.

There is also pgAdmin4 under the casks section as well.

If you want to see details of just one package, run brew list and then the name of the package. I'll do it for htop to show you what the output is like:

brew list htop
Enter fullscreen mode Exit fullscreen mode

image-15

This will show you where htop is installed.

Exporting the List of Installed Packages To a File

Before I go over this part, I just wanted to let you know that I have installed some additional packages, mostly because I need them.

Okay, once you have all of the packages and casks installed, you can create a file, or a dump, of what has been installed via Homebrew to allow you to then reinstall them quickly on a new Mac. To do this, run:

brew bundle dump
Enter fullscreen mode Exit fullscreen mode

image-16

By default, the file will be called Brewfile and it will be stored in the directory you are currently in. In my case, it is in the root of my home directory.

Let's have a look at the contents of the file in nano.

image-17

As you can see, it has a list of brew formulae / packages that have been installed, the casks and because Visual Studio Code was installed via homebrew, it also tracked the extensions that have been installed. The next time visual studio code is installed, homebrew will also install those extensions.

I'll come back to how you can use the Brewfile later.

Next, let's look at upgrading formulae and casks.

Upgrading Apps

To install the most recent version of a package or cask, the process is called upgrading. This is not to be confused with updating as that is what is used for updating homebrew itself.

To begin, run brew update. You should always do an update before an upgrade to make sure that Homebrew has the most recent version of itself installed, along with the most up-to-date package information.

image-18

As you can see, it has highlighted that there are new formulae and casks available that you can install, along with two outdated formulae that can be upgraded.

If you want to see the names and the version numbers that are installed and what they can be upgraded to, run:

brew outdated
Enter fullscreen mode Exit fullscreen mode

image-19

To perform the upgrade run:

brew upgrade
Enter fullscreen mode Exit fullscreen mode

image-20

Both of them have now been upgraded. Any casks that homebrew is responsible for will also be upgraded, if there are any so you won't have to run an upgrade just for those.

If you want to update only specific packages or casks, just add the names of the packages after brew upgrade with a space between each package name.

Now, some casks, may or may not be upgraded. The reason for this is that some apps have built-in update tools so, in those cases, Homebrew is only used to install them. After that, the app will update itself. This is set in the cask settings.

For example, Google Chrome, Firefox and Visual Studio Code will update themselves, rather than via Homebrew. pgAdmin 4 on the other hand does not update itself so the cask specifies that Homebrew will track the installed version and upgrade when required.

Clearing Cache

Homebrew maintains a cache for downloads and previous versions that were later upgraded. It's a good idea to manually clear the cache from time-to-time, if only to free up some storage.

To do that, run:

brew cleanup
Enter fullscreen mode Exit fullscreen mode

The cache will then be emptied and a summary of how much space was freed up will be shown, if there is any.

image-21

The first time I ran it, it gave no output, which indicates there is nothing to clear. I did run it again a few days later after some upgrades were done and this is what it would look like if there was some cache to clear.

image-22

Removing Packages

Removing packages is very simple to do. Simply use brew uninstall, followed by the package name. For example, to remove htop, run:

brew uninstall htop
Enter fullscreen mode Exit fullscreen mode

image-23

When I try to run it, it can't be found as it was removed.

image-24

If you want to uninstall a cask, simply delete the app from the Applications folder as normal.

Checking for Homebrew Issues

If you encounter any issues with Homebrew, you can run brew doctor which will help diagnose any issues it detects and can make recommendations on how to resolve them.

image-25

It does indicate that there is a warning about some unbrewed dylibs. I'm not going to worry about that for now but it does give you an idea of what issues it can pick up and sometimes how to resolve them.

If it doesn't find any issues but you are having trouble with something, well, it's off to Google or A.I to find a solution to the problem 🙂.

Installing Packages from a Brewfile

The last thing to cover off is how to use the Brewfile that was created earlier to do a bulk install of formulae and casks.

You can use that Brewfile on other Macs with Homebrew installed to install the same formulae and casks, or perhaps you may have reinstalled macOS and need to install everything again.

The first thing to do is make sure you are in the directory where the Brewfile is located. You can then install everything that is listed in that file by using:

brew bundle install
Enter fullscreen mode Exit fullscreen mode

Previously, htop was uninstalled and because it was listed in the Brewfile, it was installed again. Everything else was skipped as they were already installed.

image-26

When trying to run htop again, it now works.

image-27

Conclusion

That concludes this introduction of how you can use Homebrew to install and manage apps on a Mac.

Now, there are other capabilities within Homebrew that haven't been covered but it did cover most of what you would typically use it for.

Thanks for reading. Have a nice day.

Top comments (0)