4 minutes read

To install a package on Linux, one always had to run the appropriate command. However, for macOS, not all packages one needs could be installed easily. In order to simplify and automate the monotonous process of downloading and assembling packages on macOS, the Homebrew package manager was created. In this topic, we will take a closer look at what it is, how to install it and get started.

Homebrew brief history

Homebrew package manager

Homebrew is a package manager designed for installing UNIX and other open-source applications on macOS. It is distributed as free and open-source software and using it you can get any package or application you want. Homebrew will quickly download and install them and, if it is necessary, compile them from source.

Homebrew was written by Max Howell in the Ruby programming language. The first release was in 2009. In 2013, the development was funded through the Kickstarter platform. Homebrew is actively maintained by the GitHub community.

The English word Homebrew in the narrow sense means home-made beer. In a broad sense, it is any home-made product. So, the main idea of this package manager is to offer the Mac software depending on the user's taste. The creator himself calls Homebrew the missing package manager.

You can find more information on the Homebrew official website.

Below we will talk about Homebrew installation and its basic usage.

Homebrew installation

One can install Homebrew on Mac OS, Linux, and Windows Subsystem for Linux (WSL).

In order to do this, paste the following command into your terminal:

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

Then you need to follow the installation script instructions to choose the installation options. The script will inform you exactly what it will do in advance. You have to confirm everything before it continues. It will install Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon, and /home/linuxbrew/.linuxbrew for Linux) so that you will not have to use sudo when installing packages.

Note, that the script can be run even if you have stuff installed in the preferred prefix already.

If you want to use alternative installation ways, check it on the Homebrew Installation web page. In order to uninstall Homebrew, use the corresponding uninstallation script from the Homebrew GitHub.

Our next step will be getting acquainted with the Homebrew basic usage options.

Homebrew main options

To check if everything was installed correctly, use brew doctor command. In case there were no errors during installation, the command's output will be Your system is ready to brew.

Otherwise, follow the instructions on the screen to fix an error and update Homebrew.

In order to install packages, use $ brew install command. For instance, this is how one can install wget:

$ brew install wget

To uninstall the package, use the corresponding command:

$ brew uninstall wget

For further information, for example, to find out how to find and update the packages, you may use brew --help command. Here is a list of all packages available for installation.

There are also other useful options for updating and searching for packages, we will analyze them in the next section.

To find available packages to install, use the brew search command:

$ brew search git

It will return multiple packages that are available to install that have git in their name.

You can also update packages by using the upgrade command. If you type brew upgrade, it will update all the packages and applications installed. In case you need to update a specific one, type brew upgrade <package name>.

To update Homebrew itself, use brew update command.

In addition to Homebrew’s existing functionality, it also has an extension; Homebrew Cask, which we will briefly discuss in the next section.

Homebrew Cask

Homebrew Cask is a Homebrew extension that installs macOS apps, fonts and plugins, and other non-open source software. Usually, these are graphical programs, browsers, development environments, and so on. Here is a list of applications, plugins, and software that you can install with Homebrew Cask.

To use this extension add a special --cask option to the brew command. For example, to install a Firefox web browser, you will need:

$ brew install --cask firefox

In order to uninstall it, use $ brew uninstall --cask firefox command.

Conclusion

  • Homebrew is a package manager for installing UNIX and other open-source applications on macOS.
  • Homebrew can be installed on Linux as well as Windows Subsystem for Linux (WSL).
  • In order to find available installation packages, use brew search command.
  • To update the packages use brew upgrade command and to update Homebrew itself use brew update command.
  • Homebrew Cask is an extension for Homebrew for installing macOS apps, fonts and plugins, and other non-open source software.
  • In order to use Homebrew Cask add --cask to the brew command.
70 learners liked this piece of theory. 0 didn't like it. What about you?
Report a typo